From d1348a67421cdf5d79caf94b28482379e3256d95 Mon Sep 17 00:00:00 2001 From: bvtthead Date: Wed, 9 Aug 2023 10:10:55 -0400 Subject: [PATCH] follow highlight links --- lua/neogit/lib/hl.lua | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lua/neogit/lib/hl.lua b/lua/neogit/lib/hl.lua index fa75a2618..13cb4ef18 100644 --- a/lua/neogit/lib/hl.lua +++ b/lua/neogit/lib/hl.lua @@ -29,17 +29,23 @@ end ---@param name string Syntax group name. local function get_fg(name) - local color = vim.api.nvim_get_hl(0, { name = name })["fg"] - if color then - return "#" .. to_hex(color) + local color = vim.api.nvim_get_hl(0, { name = name }) + if color["link"] then + return get_fg(color["link"]) + end + if color["fg"] then + return "#" .. to_hex(color["fg"]) end end ---@param name string Syntax group name. local function get_bg(name) - local color = vim.api.nvim_get_hl(0, { name = name })["bg"] - if color then - return "#" .. to_hex(color) + local color = vim.api.nvim_get_hl(0, { name = name }) + if color["link"] then + return get_bg(color["link"]) + end + if color["bg"] then + return "#" .. to_hex(color["bg"]) end end