HiPhish / rainbow-delimiters.nvim

Rainbow delimiters for Neovim with Tree-sitter
https://gitlab.com/HiPhish/rainbow-delimiters.nvim
Apache License 2.0
490 stars 37 forks source link

[Feature]: Move to more standard `.setup()` function for configuration #4

Closed mehalter closed 1 year ago

mehalter commented 1 year ago

Sorry, there isn't an option for suggestions/feature request. I just wanted to recommend moving to the more standard .setup() function for setting up and configuring the plugin rather than the vim.g variable. This would make the plugin very easy to configure with plugin managers such as Lazy and align with the configuring of most other Neovim plugins.

mehalter commented 1 year ago

hey @HiPhish I noticed you added this in the latest commit, this actually isn't the standard approach because you need to do require("rainbow-delimiters.setup")(...) which isn't compatible with any of the plugin managers due to it being so different. It should be require("rainbow-delimiters").setup(...)

HiPhish commented 1 year ago

This is implemented in the current master now. However, the module is rainbow-delimiters.setup. I made it a separate module because it it creates a function which users of g:rainbow_delimiters do not need. Please close the issue if it works for you.

the more standard .setup() function

There is nothing standard about the setup function. It is a hack from the early days of Lua integration when you could not easily transfer values between Vim script and Lua, but these days it's just a cargo cult ritual popularized by YouTubers.

plugin managers such as Lazy

There is nothing standard about lazy.nvim either. It's just one guy's opinion of how he wants to configure his plugins, and you may or may not like his opinion, but plugins should not have to bend over backwards to accommodate it. In this case it's not a big deal, so I don't mind having the option for those who really want it.

HiPhish commented 1 year ago

hey @HiPhish I noticed you added this in the latest commit, this actually isn't the standard approach because you need to do require("rainbow-delimiters.setup")(...) which isn't compatible with any of the plugin managers due to it being so different. It should be require("rainbow-delimiters").setup(...)

I'm sorry, but then it's your plugin manager's fault for locking you into a specific workflow. I think this is something that should be solved by the plugin manager because then all the plugins which don't use setup will profit as well. There are a lot of good plugins that predate Lua or even Neovim itself.

The issue with adding a setup function to the rainbow-delimiters module is that it introduces the overhead of defining and interning an extra function. This might not be much for one plugin, but if every plugin keeps doing this it adds up. I really wish we could stop this malpractice. These setup functions don't do anything other than just defining another variable anyway, so why have that middleman in the first place?

mehalter commented 1 year ago

❤️ I appreciate your insight into the problem. It would be nice to have this contributed to the greater community as well to help guide the development 😺

xigoi commented 11 months ago

On the contrary, I'd say that using a global variable for configuration is a hack from the old days of VimScript where there wasn't a good way to have module-level encapsulation.

thetic commented 9 months ago

I've reworked the rainbow-delimiters.setup module to play more nicely with common plugin managers: https://github.com/HiPhish/rainbow-delimiters.nvim/pull/44. I'd appreciate any feedback.