refactor: move out function to retrieve highlight

This commit is contained in:
2025-05-02 23:31:41 +02:00
parent 7de0efdc5e
commit 3c4a96442a
2 changed files with 13 additions and 10 deletions
+3 -10
View File
@@ -1,19 +1,12 @@
local function find_link_source(name) local utils = require("ow.utils")
local hl = vim.api.nvim_get_hl(0, { name = "NvimTreeFileIcon" })
while hl.link do
hl = vim.api.nvim_get_hl(0, { name = hl.link })
end
return hl
end
local function override_highlights() local function override_highlights()
-- File Icon -- File Icon
local hl = find_link_source("NvimTreeFileIcon") local hl = utils.get_hl_source("NvimTreeFileIcon")
vim.api.nvim_set_hl(0, "NvimTreeFileIcon", { fg = hl.fg, bg = nil }) vim.api.nvim_set_hl(0, "NvimTreeFileIcon", { fg = hl.fg, bg = nil })
-- Symlink Icon -- Symlink Icon
hl = find_link_source("NvimTreeSymlinkIcon") hl = utils.get_hl_source("NvimTreeSymlinkIcon")
vim.api.nvim_set_hl( vim.api.nvim_set_hl(
0, 0,
"NvimTreeSymlinkIcon", "NvimTreeSymlinkIcon",
+10
View File
@@ -395,4 +395,14 @@ function M.debounce_with_id(fn, delay)
end end
end end
function M.get_hl_source(name)
local hl = vim.api.nvim_get_hl(0, { name = name })
while hl.link do
hl = vim.api.nvim_get_hl(0, { name = hl.link })
end
return hl
end
return M return M