Skip to content

Commit f8317cc

Browse files
committed
feat: add hl_group for file icons
1 parent 00fd8ae commit f8317cc

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
@@ -792,6 +792,7 @@ NvimTreeSymlink
792792
NvimTreeFolderName
793793
NvimTreeRootFolder
794794
NvimTreeFolderIcon
795+
NvimTreeFileIcon
795796
NvimTreeEmptyFolderName
796797
NvimTreeOpenedFolderName
797798
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(fname, extension, 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)