Skip to content

plugins/rainbow: init #3574

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

saygo-png
Copy link
Contributor

@saygo-png saygo-png commented Jul 21, 2025

https://github.com/luochen1990/rainbow/

Something easier to review from me this time.

This plugin adds rainbow parentheses. I'm aware that we already have rainbow-delimiters, but that uses treesitter. Not everyone likes that project. Even though I do use treesitter I find that this non TS implementation works much faster and does the same thing.

I enable the active setting by default because that is described as part of "setup" in the upstream documentation.

@GaetanLepage
Copy link
Member

When you create such a PR, can you include a link to the plugin's homepage?

I enable the active setting by default because that is described as part of "setup" in the upstream documentation.

I don't think that this is a reason for us to enable it by default.
If the default value is 0, then we should leave that.

Also, can you add settingsExample and an example test case in the test file please?

@saygo-png saygo-png force-pushed the plugins-rainbow-init branch from b4239ad to 084c135 Compare July 22, 2025 17:00
@saygo-png
Copy link
Contributor Author

When you create such a PR, can you include a link to the plugin's homepage?

Sure thing.

I don't think that this is a reason for us to enable it by default. If the default value is 0, then we should leave that.

Removed it.

Also, can you add settingsExample and an example test case in the test file please?

Added an extensive example taken mostly from upstream, i only changed one of the colors to a hex notation to show that you can also define colors that way.

Copy link
Member

@GaetanLepage GaetanLepage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very promising! A few minor remarks.

maintainers = [ lib.maintainers.saygo-png ];
globalPrefix = "rainbow_";

settingsExample = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can leave the example test case as is, but settingsExample here is used to generate the documentation. Hence, it would be better to shorten it to 5-10 options, otherwise it becomes quite unreadable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The defaults set by the plugin are almost identical to the example i took from the readme. So the default and example test cases almost test the same thing. Should i remove the example test case because of that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preferred to have settingsExample and example be more real world configuration examples.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preferred to have settingsExample and example be more real world configuration examples.

I can't really come up with anything more practical here. The issue is that the configuration for this plugin is mostly just colors, the rest is defined by default and works well. Majority of the fancy options are for fixing compatibility with other plugins but I've never had to use them.

Current example does show how you can disable filetypes, basic regex escaping from nix, and configure the colors which id wager is what most people will ever do with this plugin's configuration.

empty = {
plugins.rainbow.enable = true;
};

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add a defaults test case that explicitly sets each option to its default value, as documented upstream?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added what i could, but sadly i just don't have the regex skills to properly escape these complex expressions in nix, in such a way that they also get escaped in lua while preserving their original meaning.
You can see what is missing from the defaults and the regex horror here: https://github.com/luochen1990/rainbow/blob/76ca1a20aa42edb5c65c19029968aad4625790dc/autoload/rainbow_main.vim

@saygo-png saygo-png force-pushed the plugins-rainbow-init branch from 084c135 to 55d1f98 Compare July 26, 2025 13:44
Signed-off-by: saygo-png <[email protected]>
@saygo-png saygo-png force-pushed the plugins-rainbow-init branch from 55d1f98 to 533dbbf Compare August 6, 2025 15:56
@khaneliman khaneliman requested a review from GaetanLepage August 6, 2025 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants