Iron-E / nvim-libmodal

Create new "modes" for Neovim!
Other
118 stars 7 forks source link

consider move initialization to lua #10

Closed matu3ba closed 2 years ago

matu3ba commented 3 years ago

I like the plugin very much. Thanks alot for creating! Since you do setups functional anyway, why not provide one for your plugin initialisation? This would enable stuff like conditional setups for users etc.

Reasons to do:

  1. A pure lua profile would decrease startup time.
  2. The lua startup profiler would be more correct or simpler to get correct with this change. Otherwise one gets more wrong results.
  3. Try to be consistent as to use functionality of lua, if possible.
  4. Having a function to initialize makes separating things for user-specific settings while getting updates much easier (user may implement a different function to customize plugin).

Another related reason (bad practice/historical reasons): nvim-treesitter/module-template#1

Potentially related discussion for galaxyline: https://github.com/glepnir/galaxyline.nvim/issues/134

Relevant content for change:

if vim.g.loaded_libmodal == nil
  --finish stuff
end
vim.g.loaded_libmodal = 1;
if vim.o.timeout == nil -- timeout is an option, which should always exist => could be a bug in your code
    vim.o.timeout = true;
end
--highlight default link LibmodalPrompt ModeMsg --please check how pure lua plugins do this or the colorbuddy source
--highlight default link LibmodalStar StatusLine

Of course you could also use the more optimal vim.api functions for setting and getting variables as described in the nvim-lua-guide.

Iron-E commented 3 years ago

Thanks for your interest in this plugin! I will say that I am interested in doing this, since I love Lua.

I have been waiting for neovim/neovim#12670 to be resolved before implementing something like this, so I can map the plugin directory directly to the lua folder. It seems like this will be a 0.6 feature, though.

I wonder if putting this logic in the init.lua could be equivalent for our purposes. This would be like lazy-loading and also would be backwards compatible with Neovim 0.4+.

We wouldn't need if vim.g.loaded_libmodal, since init.luas are only loaded once.

At the moment I'm chugging away on CLInvoice so I'll have to put this on the backlog for now, but I will pick this back up to see what I can see in a little bit!

Iron-E commented 3 years ago

I have added a branch which implements this feature. I will merge it after the release of 0.5; feel free to test it!

Iron-E commented 3 years ago

I'm getting ready to merge the branch. Can you checkout the branch and tell me if there are any breakages? I've tested from my side and things are fine, but it's good to check.

matu3ba commented 3 years ago

@Iron-E Unfortunately so far I did not configure libmodal. :( Currently I am focusing on REPL and per-project configuration and more minimal tasks, once I have some spare time.

Iron-E commented 2 years ago

We now use Lua init as of 2.0.0

Thank you again for the sugggestion!