Skip to content

Commit 924aa29

Browse files
authored
feat: add hl_group for file icons (#1131)
1 parent 6368880 commit 924aa29

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

doc/nvim-tree-lua.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,7 @@ NvimTreeSymlink
801801
NvimTreeFolderName
802802
NvimTreeRootFolder
803803
NvimTreeFolderIcon
804+
NvimTreeFileIcon
804805
NvimTreeEmptyFolderName
805806
NvimTreeOpenedFolderName
806807
NvimTreeExecFile

lua/nvim-tree/renderer/init.lua

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,13 @@ if icon_state.show_file_icon then
8383
end
8484
end
8585
else
86-
get_file_icon = function()
87-
return #icon_state.icons.default > 0 and icon_state.icons.default .. icon_padding or ""
86+
get_file_icon = function(_, _, line, depth)
87+
local hl_group = "NvimTreeFileIcon"
88+
local icon = icon_state.icons.default
89+
if #icon > 0 then
90+
table.insert(hl, { hl_group, line, depth, depth + #icon + 1 })
91+
end
92+
return #icon > 0 and icon .. icon_padding or ""
8893
end
8994
end
9095
end

0 commit comments

Comments
 (0)