fix(util.ui.fg): Add link=false to show effective definition

Fixes #2540 by showing the effective definition instead of the linked
group name.
This commit is contained in:
Iordanis Petkakis 2024-02-12 21:48:08 +02:00
parent a50f92f755
commit b19d99105c

View file

@ -142,7 +142,8 @@ end
function M.fg(name)
---@type {foreground?:number}?
---@diagnostic disable-next-line: deprecated
local hl = vim.api.nvim_get_hl and vim.api.nvim_get_hl(0, { name = name }) or vim.api.nvim_get_hl_by_name(name, true)
local hl = vim.api.nvim_get_hl and vim.api.nvim_get_hl(0, { name = name, link = false })
or vim.api.nvim_get_hl_by_name(name, true)
---@diagnostic disable-next-line: undefined-field
local fg = hl and (hl.fg or hl.foreground)
return fg and { fg = string.format("#%06x", fg) } or nil