From c16126618932a58d2fac35f2d96bd83f67a261e4 Mon Sep 17 00:00:00 2001 From: xsbsy-hzbyp Date: Wed, 7 Oct 2026 08:50:02 +0800 Subject: [PATCH] fix(nvim-tree#3359): link to the defined legacy highlight if the new one only links to default --- lua/nvim-tree/appearance/init.lua | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/lua/nvim-tree/appearance/init.lua b/lua/nvim-tree/appearance/init.lua index 9918ca4dd0b..fcf3142666e 100644 --- a/lua/nvim-tree/appearance/init.lua +++ b/lua/nvim-tree/appearance/init.lua @@ -193,10 +193,24 @@ function M.highlight() -- hard link override when legacy only is present for from, to in pairs(M.LEGACY_LINKS) do - local hl_from = vim.api.nvim_get_hl(0, { name = from }) local hl_to = vim.api.nvim_get_hl(0, { name = to }) - if vim.tbl_isempty(hl_from) and not vim.tbl_isempty(hl_to) then - vim.api.nvim_command("hi link " .. from .. " " .. to) + if not vim.tbl_isempty(hl_to) then + local hl_from = vim.api.nvim_get_hl(0, { name = from }) + + -- check if it simply links to the default + local link_default = false + if hl_from.link then + for _, g in ipairs(M.HIGHLIGHT_GROUPS) do + if g.group == from then + link_default = (hl_from.link == g.link) + break + end + end + end + + if vim.tbl_isempty(hl_from) or link_default then + vim.api.nvim_command("hi link " .. from .. " " .. to) + end end end