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

feat: allow clearing a color with highlight group #1709

Closed

Conversation

ramojus
Copy link

@ramojus ramojus commented Jan 12, 2025

Implements #1306.

I couldn't confidently determine if the value really was "NONE" - the method used by this plugin returns nil and vim.api.nvim_get_hl(0, { name = <hlgroup> }) returns vim.empty_dict().

With this change, if the highlight links to a non-existing group, it will be transparent. I couldn't think of a way to avoid this.

EDIT: I was planning to investigate this a bit more, but accidentally submitted the PR. I think this could be a valid solution, so I'm leaving it as is for now.

@ramojus ramojus changed the title wfeat: allow clearing a color with highlight group feat: allow clearing a color with highlight group Jan 13, 2025
@ibhagwan
Copy link
Owner

I couldn't confidently determine if the value really was "NONE"

EDIT: I was planning to investigate this a bit more, but accidentally submitted the PR. I think this could be a valid solution, so I'm leaving it as is for now.

Obviously the best would be if can accurately determine the hlgroup was set to NONE, I'm wondering if that's possible, I'll do some quick tests and also think on potential downsides to setting a color to -1.

@ibhagwan
Copy link
Owner

I also couldn't find a way between NONE values and not having the value defined at all, not with lua API nor vimL.

The issue with setting -1 in this case is that it nullifies the fzf colorscheme, say someone has a NONE def for the fg of the Special hlgroup, by default (with fzf_colors=true) it will be linked to FzfLuaFzfMatch which will then nullify all fuzzy matching colors (bad, can't match anything).

I'm not sure we can allow this type of downside vs forcing the user to add -1 to their fzf_colors.

@ramojus
Copy link
Author

ramojus commented Jan 18, 2025

I agree that that would not be a good behavior.
What if we checked whether the highlight definition is still the default one and only set -1 if that's not the case? Shouldn't be too difficult to do.

EDIT: It's actually quite a bit more difficult than I thought :D But I'm invested now, so I will finish it anyways. I will understand if you don't want the complexity for such minor functionality.

@ramojus
Copy link
Author

ramojus commented Jan 18, 2025

More of a draft and needs more testing. This might still be strange, if the users definition matches the default one...
We could also mark the places where user specifically sets their own colors and setup an autocmd to check if user changes highlights (is there such event though?).

Anyways, I'll be waiting for your thoughts. Feel free to close the PR now if you think this is too much & not worth it, as I don't have anything better to suggest.

@ibhagwan
Copy link
Owner

Appreciate the effort @ramojus but it feels very hacky and doesn’t cover everything, I think this change will have to wait until there is better detection for NONE in neovim, until then I can live with having to specify -1.

@ibhagwan ibhagwan closed this Jan 18, 2025
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.

None yet

2 participants