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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use named color names #134

Merged
merged 1 commit into from
Jul 1, 2023
Merged

Conversation

lucassperez
Copy link
Contributor

@lucassperez lucassperez commented Jul 1, 2023

So it appears that the commit c29c2a1 makes the Hlgroup.new call get_hex on both fg and bg, but get_hex returns an empty string when we pass a name, like red. So we cannot set a component like this anymore:

{
  text = ...,
  fg = 'red',
}

Before it just simply passed the value as is to a vim.cmd('highlight ...'), so we could use color names without a problem.

I think it is nice to able to get the color of a hlgroup, which is what the mentioned commit does, so I think we should definitely keep that. I then started looking at the code and noticed that it looks at the first character passed to fg (or bg) and checks if it is a # to decide if the user passed a hlgroup name or a color.

After weird workarounds (that included hardcoding some names 馃槄 - not good workarounds) and some googleing around, I found out that vim has a function hlexists, which receives a string and returns 0 if a hlgroup with that name does not exist and 1 if it does.

So I think we could change the check to use that function instead of looking if the first character of the string is # or not.

What do you think?

@willothy
Copy link
Owner

willothy commented Jul 1, 2023

Perfect! I was looking for a less naive solution to this.

@willothy willothy merged commit d1a9655 into willothy:main Jul 1, 2023
4 checks passed
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