nvim-neorocks / nvim-best-practices

Collection of DOs and DON'Ts for modern Neovim Lua plugin development
Creative Commons Zero v1.0 Universal
310 stars 7 forks source link

Auto require plugin #16

Closed Willem-J-an closed 3 months ago

Willem-J-an commented 3 months ago

I followed some of the instructions in here for my new plugin. I did the vim.g config table, and created a single command with autocompletion. Now I'm wondering about this, provided I have a lua/myplugin.lua which creates my magnificent autocompletion command, is it okay for me to have a plugin/init.lua file which requires('myplugin')? My plugin lazy loads everything when required as suggested in this repo.

Having the auto self require will make the command directly available to the users, so they don't have to require my plugin in their config. Curious about the best practice on this point.

mrcjkb commented 3 months ago

Hey 👋

Having the auto self require will make the command directly available to the users, so they don't have to require my plugin in their config.

Yep, I would recommend that (see the initialisation section).

It can be a good idea to create the commands in the plugin/ script, in such a way that nothing needs to be required during initialisation.