Closed budswa closed 2 years ago
It seems that nvim_get_hl_id_by_name
gives strange results when trying to extract from a linked hl group, in this case, your theme links CursorLine
to CursorColumn
.
@mvllow any reason why you use nvim_get_hl_id_by_name
instead of nvim_get_hl_by_name
?
@budswa BTW, before I make a PR, you can try the following patch to fix this behavior or you can define CursorLine
instead of linking it
diff --git a/lua/modes/util.lua b/lua/modes/util.lua
index bc657c8..43c8714 100644
--- a/lua/modes/util.lua
+++ b/lua/modes/util.lua
@@ -47,6 +47,11 @@ function util.hl(group, color)
end
function util.get_fg_from_hl(hl_name, fallback)
+ local ok, hl = pcall(vim.api.nvim_get_hl_by_name, hl_name, true)
+ if ok and hl.background then
+ return ('#%06x'):format(hl.background)
+ end
+
local id = vim.api.nvim_get_hl_id_by_name(hl_name)
if not id then
return fallback
@@ -61,6 +66,11 @@ function util.get_fg_from_hl(hl_name, fallback)
end
function util.get_bg_from_hl(hl_name, fallback)
+ local ok, hl = pcall(vim.api.nvim_get_hl_by_name, hl_name, true)
+ if ok and hl.background then
+ return ('#%06x'):format(hl.background)
+ end
+
local id = vim.api.nvim_get_hl_id_by_name(hl_name)
if not id then
return fallback
@mvllow any reason why you use nvim_get_hl_id_by_name instead of nvim_get_hl_by_name ?
Didn't know the latter existed. Thank you for debugging this issue 🥰
Hi. When starting Neovim my normal CursorLine highlights are used but after going into insert or visual mode and returning into normal mode or if I press escape after startup, staying in normal mode, the CursorLine highlight isn't properly applied.
On startup:
After entering insert/visual mode and returning to normal mode or pressing escape:
The result of me running
:hi CursorLine
shows me that its guibg value isGrey40
, rather than the expected hex value. The highlight is defined by my colorscheme. I believe what I'm seeing is some sort of fallback highlight, which isn't based on the CursorLine highlight.Thanks