Skip to content

Commit

Permalink
fix(utils): hl-Statusline retrieval issue in toggleterm
Browse files Browse the repository at this point in the history
This commit should fix a weird bug where `nvim_get_hl` would return an empty
dict when trying to get `hl-Statusline` inside `toggleterm`. Not 100% sure why
this was happening or what exact conditions caused it, but with this fix lualine
now shows the right backgrounds in terminal mode!

Signed-off-by: Jint-lzxy <[email protected]>
  • Loading branch information
Jint-lzxy committed Jan 20, 2025
1 parent 7b095f8 commit 3ea94e7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lua/modules/utils/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ function M.hl_to_rgb(hl_group, use_bg, fallback_hl)
local hlexists = pcall(vim.api.nvim_get_hl, 0, { name = hl_group, link = false })

if hlexists then
local result = vim.api.nvim_get_hl(0, { name = hl_group, link = false })
-- FIXME: Investigate why hl-StatusLine is undefined in toggleterm and remove this workaround
local link = vim.bo.filetype == "toggleterm"
local result = vim.api.nvim_get_hl(0, { name = hl_group, link = link })
if use_bg then
hex = result.bg and string.format("#%06x", result.bg) or "NONE"
else
Expand Down

0 comments on commit 3ea94e7

Please sign in to comment.