@@ -4,15 +4,19 @@ local HL_POSITION = require("nvim-tree.enum").HL_POSITION
4
4
local ICON_PLACEMENT = require (" nvim-tree.enum" ).ICON_PLACEMENT
5
5
6
6
local Decorator = require (" nvim-tree.renderer.decorator" )
7
+ local DirectoryNode = require (" nvim-tree.node.directory" )
7
8
8
9
--- @class HighlightedStringGit : HighlightedString
9
10
--- @field ord number decreasing priority
10
11
12
+ --- @alias IconsByStatus table<string , HighlightedStringGit[]> by human status
13
+ --- @alias IconsByXY table<string , HighlightedStringGit[]> by porcelain status
14
+
11
15
--- @class (exact ) DecoratorGit : Decorator
12
16
--- @field file_hl table<string , string> ? by porcelain status e.g. " AM"
13
17
--- @field folder_hl table<string , string> ? by porcelain status
14
- --- @field icons_by_status HighlightedStringGit[] ? by human status
15
- --- @field icons_by_xy table<string , HighlightedStringGit[]> ? by porcelain status
18
+ --- @field icons_by_status IconsByStatus ?
19
+ --- @field icons_by_xy IconsByXY ?
16
20
local DecoratorGit = Decorator :new ()
17
21
18
22
--- Static factory method
@@ -49,7 +53,7 @@ function DecoratorGit:create(opts, explorer)
49
53
return o
50
54
end
51
55
52
- --- @param glyphs table<string , string> user glyps
56
+ --- @param glyphs IconsByStatus user glyps
53
57
function DecoratorGit :build_icons_by_status (glyphs )
54
58
self .icons_by_status = {
55
59
staged = { str = glyphs .staged , hl = { " NvimTreeGitStagedIcon" }, ord = 1 },
@@ -62,7 +66,7 @@ function DecoratorGit:build_icons_by_status(glyphs)
62
66
}
63
67
end
64
68
65
- --- @param icons HighlightedStringGit[]
69
+ --- @param icons IconsByXY
66
70
function DecoratorGit :build_icons_by_xy (icons )
67
71
self .icons_by_xy = {
68
72
[" M " ] = { icons .staged },
@@ -214,7 +218,7 @@ function DecoratorGit:calculate_highlight(node)
214
218
return nil
215
219
end
216
220
217
- if node . nodes then
221
+ if node : is ( DirectoryNode ) then
218
222
return self .folder_hl [git_status [1 ]]
219
223
else
220
224
return self .file_hl [git_status [1 ]]
0 commit comments