refactor: move out function to retrieve highlight
This commit is contained in:
@@ -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",
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user