Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consider move initialization to lua #10

Closed
matu3ba opened this issue Apr 11, 2021 · 5 comments
Closed

consider move initialization to lua #10

matu3ba opened this issue Apr 11, 2021 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@matu3ba
Copy link

matu3ba commented Apr 11, 2021

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: nvimdev/galaxyline.nvim#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 Iron-E self-assigned this Apr 11, 2021
@Iron-E Iron-E added the enhancement New feature or request label Apr 11, 2021
@Iron-E
Copy link
Owner

Iron-E commented Apr 11, 2021

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 added a commit that referenced this issue Jun 13, 2021
@Iron-E
Copy link
Owner

Iron-E commented Jun 13, 2021

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
Copy link
Owner

Iron-E commented Jul 7, 2021

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
Copy link
Author

matu3ba commented Jul 8, 2021

@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
Copy link
Owner

Iron-E commented Apr 24, 2022

We now use Lua init as of 2.0.0

Thank you again for the sugggestion!

@Iron-E Iron-E closed this as completed Apr 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants