Lua config equivalent of `pack\plugins\opt\{name}` directory

Hi,

I was wondering where I should locate I very small set of functions I ended up writing (resembling to a plugin hence, but not installed via any of the available plugin managers), but that I want to load using require("plugin-name") in an autocommand when something specific fires.
I tried the built-in Vim directory as in the title, but didn’t work.

Thanks

Create a directory called lua in the plugins directory, then put the code into a file named plugin_name.lua. In the lua return your functions in an object.
Alternatively instead of one file, you can create directory which name should be plugin_name and add an init.lua function to it.
Then you can call require('plugin_name').function_name()

For example pack/plugins/opt/asdf/lua/asdf.lua or pack/plugins/opt/asdf/lua/asfd/init.lua

return {
  fubar = function()
    print("asdf")
  end
}

:lua require('asdf').fubar()

1 Like

@Ajnasz , thanks a lot for your answer!

This didn’t really work, and I’m still wondering why. I’ll try the second approach you suggest as soon as I can.

I’ll keep you updated!

It might be an issues that it’s in opt folder, so it won’t load automatically. You might want to call :packadd asdf first or put into the start folder instead