-
-
Notifications
You must be signed in to change notification settings - Fork 219
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
Themes with highlight groups using "links" to other groups do not propagate colors to SwiftUI properly #1069
Comments
I think I use a couple of plugins which do the link decode in lua. Take a look at lualine source - I think it decodes highlights to get the separators right in a highlight module. GeorgeOn May 28, 2024, at 6:36 AM, S David ***@***.***> wrote:
I think I figured out why another bug where some themes do not propagate their theme colors to VimR, such as dracula.
I noticed color changes are propagated from
In NvimView+Resize.swift, line 129
autocmd ColorScheme * call rpcnotify(\(channel), 'autocommand', 'colorscheme', get(nvim_get_hl(0, {'id': hlID('Normal')}), 'fg', -1), get(nvim_get_hl(0, {'id': hlID('Normal')}), 'bg', -1), get(nvim_get_hl(0, {'id': hlID('Visual')}), 'fg', -1), get(nvim_get_hl(0, {'id': hlID('Visual')}), 'bg', -1), get(nvim_get_hl(0, {'id': hlID('Directory')}), 'fg', -1), get(nvim_get_hl(0, {'id': hlID('TablineSel')}), 'bg', -1), get(nvim_get_hl(0, {'id': hlID('TablineSel')}), 'fg', -1))
But when I try to get those specific groups in neovim:
echo get(nvim_get_hl(0, {'id': hIID('TablineSel')}, 'fg')
['bold': vitrue, 'cterm': {'bold': vitrue}, 'link': 'Normal'})
echo get(nvim_get_hl(0, {'id': hIID('TablineFill')}, 'fg')
({'link': 'DraculaBgDark'})
When using the existing code, get(nvim_get_hl(0, {'id': hlID('TablineFill')}), 'bg', -1), the result with these highlight groups is always -1, becaus ethese specific groups have their values "linked" to other highlight groups.
Looking at the neovim documentation, they suggest using something more like synIDattr(synIDtrans(hlID('TablineFill')),'bg').
Trying it in my clients, I get:
echo synIDattr(synIDtrans(hlID('TablineFill')),'bg')
#21222c
echo synIDattr(synIDtrans(hlID('TablineFill')),'fg')
This is a lot better, with hex color codes starting with #, but it results in empty strings when there is no value set, which could affect how existing code handles missing color codes.
I'm working on a pull-request, but I wanted to also have this issue to explain the problem.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
@georgeharker That's not a bad suggestion, but where possible, it's probably best to let the neovim runtime do all the hard work. I found that using the builtin funtionss as such follows all links automatically: synIDattr(synIDtrans(hlID(<GroupName>)), <fg|bg>) " -> returns '#rrggbb' or '' I got the following vimscript function to behave like get() when the result is not found function! GetHiColor(hlID, component)
let color = synIDattr(synIDtrans(hlID(a:hlID)), a:component)
if empty(color)
return -1
else
return str2nr(color[1:], 16) "removes leading # and converts hex string to its int value
endif
endfunction
echo GetHiColor('TabLineFill', 'bg') " -> 2171436
echo get(nvim_get_hl(0, {'id': hlID('TabLineFill')}), 'bg', -1) " -> -1 |
s-daveb
added a commit
to s-daveb/vimr
that referenced
this issue
May 29, 2024
…n a more robust way. See qvacua#1069
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think I figured out why another bug where some themes do not propagate their theme colors to VimR, such as dracula.
I noticed color changes are propagated from
In NvimView+Resize.swift, line 129
But when I try to get those specific groups in neovim:
Because some themes define highlight groups that pull their values from other groups ("link" to other groups), when using the existing code,
get(nvim_get_hl(0, {'id': hlID('TablineFill')}), 'bg', -1)
, the result with these highlight groups is always -1.Reading up on highlight groups in the neovim docs, they suggest using something more like
synIDattr(synIDtrans(hlID('TablineFill')),'bg')
.Trying it in my clients, I get:
This is a lot better, returning with hex color codes starting with #, but it results in empty strings when there is no value set, which could affect how existing code handles missing color codes.
I'm working on a pull-request that changes how the colors are grabbed, without changing how their error handling ( value of -1 ) works; but I wanted to also have this issue to explain the problem.
The text was updated successfully, but these errors were encountered: