Skip to content

Commit 4a24950

Browse files
committed
annotate decorators
1 parent 769ba17 commit 4a24950

File tree

8 files changed

+48
-27
lines changed

8 files changed

+48
-27
lines changed

lua/nvim-tree/renderer/decorator/bookmarks.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,18 @@ function DecoratorBookmarks:new(opts)
3030
return o
3131
end
3232

33-
--- Bookmark icon: renderer.icons.show.bookmarks and node is marked
33+
---Bookmark icon: renderer.icons.show.bookmarks and node is marked
34+
---@param node Node
35+
---@return HighlightedString[]|nil icons
3436
function DecoratorBookmarks:calculate_icons(node)
3537
if marks.get_mark(node) then
3638
return { self.icon }
3739
end
3840
end
3941

40-
--- Bookmark highlight: renderer.highlight_bookmarks and node is marked
42+
---Bookmark highlight: renderer.highlight_bookmarks and node is marked
43+
---@param node Node
44+
---@return string|nil group
4145
function DecoratorBookmarks:calculate_highlight(node)
4246
if self.hl_pos ~= HL_POSITION.none and marks.get_mark(node) then
4347
return "NvimTreeBookmarkHL"

lua/nvim-tree/renderer/decorator/copied.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ function DecoratorCopied:new(opts)
2626
return o
2727
end
2828

29-
--- Cut highlight: renderer.highlight_clipboard and node is copied
29+
---Copied highlight: renderer.highlight_clipboard and node is copied
30+
---@param node Node
31+
---@return string|nil group
3032
function DecoratorCopied:calculate_highlight(node)
3133
if self.hl_pos ~= HL_POSITION.none and copy_paste.is_copied(node) then
3234
return "NvimTreeCopiedHL"

lua/nvim-tree/renderer/decorator/cut.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ function DecoratorCut:new(opts)
2626
return o
2727
end
2828

29-
--- Cut highlight: renderer.highlight_clipboard and node is cut
29+
---Cut highlight: renderer.highlight_clipboard and node is cut
30+
---@param node Node
31+
---@return string|nil group
3032
function DecoratorCut:calculate_highlight(node)
3133
if self.hl_pos ~= HL_POSITION.none and copy_paste.is_cut(node) then
3234
return "NvimTreeCutHL"

lua/nvim-tree/renderer/decorator/diagnostics.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ function DecoratorDiagnostics:new(opts)
6262
return o
6363
end
6464

65-
--- Diagnostic icon: diagnostics.enable, renderer.icons.show.diagnostics and node has status
65+
---Diagnostic icon: diagnostics.enable, renderer.icons.show.diagnostics and node has status
66+
---@param node Node
67+
---@return HighlightedString[]|nil icons
6668
function DecoratorDiagnostics:calculate_icons(node)
6769
if node and self.enabled and self.icons then
6870
if node.diag_status then
@@ -71,7 +73,9 @@ function DecoratorDiagnostics:calculate_icons(node)
7173
end
7274
end
7375

74-
--- Diagnostic highlight: diagnostics.enable, renderer.highlight_diagnostics and node has status
76+
---Diagnostic highlight: diagnostics.enable, renderer.highlight_diagnostics and node has status
77+
---@param node Node
78+
---@return string|nil group
7579
function DecoratorDiagnostics:calculate_highlight(node)
7680
if not node or not self.enabled or self.hl_pos == HL_POSITION.none then
7781
return nil

lua/nvim-tree/renderer/decorator/git.lua

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ function DecoratorGit:build_hl_table()
137137
end
138138
end
139139

140-
--- Git icons: git.enable, renderer.icons.show.git and node has status
141-
---@param node table
140+
---Git icons: git.enable, renderer.icons.show.git and node has status
141+
---@param node Node
142142
---@return HighlightedString[]|nil modified icon
143143
function DecoratorGit:calculate_icons(node)
144144
if not node or not self.enabled or not self.icons_by_xy then
@@ -184,7 +184,9 @@ function DecoratorGit:calculate_icons(node)
184184
return iconss
185185
end
186186

187-
--- Get the first icon as the sign if appropriate
187+
---Get the first icon as the sign if appropriate
188+
---@param node Node
189+
---@return string|nil name
188190
function DecoratorGit:sign_name(node)
189191
if self.icon_placement ~= ICON_PLACEMENT.signcolumn then
190192
return
@@ -196,7 +198,9 @@ function DecoratorGit:sign_name(node)
196198
end
197199
end
198200

199-
--- Git highlight: git.enable, renderer.highlight_git and node has status
201+
---Git highlight: git.enable, renderer.highlight_git and node has status
202+
---@param node Node
203+
---@return string|nil group
200204
function DecoratorGit:calculate_highlight(node)
201205
if not node or not self.enabled or self.hl_pos == HL_POSITION.none then
202206
return nil

lua/nvim-tree/renderer/decorator/init.lua

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ function Decorator:new(o)
1717
return o
1818
end
1919

20-
--- Maybe highlight groups
21-
---@param node table
20+
---Maybe highlight groups
21+
---@param node Node
2222
---@return string|nil icon highlight group
2323
---@return string|nil name highlight group
2424
function Decorator:groups_icon_name(node)
@@ -38,8 +38,8 @@ function Decorator:groups_icon_name(node)
3838
return icon_hl, name_hl
3939
end
4040

41-
--- Maybe icon sign
42-
---@param node table
41+
---Maybe icon sign
42+
---@param node Node
4343
---@return string|nil name
4444
function Decorator:sign_name(node)
4545
if not self.enabled or self.icon_placement ~= ICON_PLACEMENT.signcolumn then
@@ -52,8 +52,8 @@ function Decorator:sign_name(node)
5252
end
5353
end
5454

55-
--- Icons when ICON_PLACEMENT.before
56-
---@param node table
55+
---Icons when ICON_PLACEMENT.before
56+
---@param node Node
5757
---@return HighlightedString[]|nil icons
5858
function Decorator:icons_before(node)
5959
if not self.enabled or self.icon_placement ~= ICON_PLACEMENT.before then
@@ -63,8 +63,8 @@ function Decorator:icons_before(node)
6363
return self:calculate_icons(node)
6464
end
6565

66-
--- Icons when ICON_PLACEMENT.after
67-
---@param node table
66+
---Icons when ICON_PLACEMENT.after
67+
---@param node Node
6868
---@return HighlightedString[]|nil icons
6969
function Decorator:icons_after(node)
7070
if not self.enabled or self.icon_placement ~= ICON_PLACEMENT.after then
@@ -74,23 +74,23 @@ function Decorator:icons_after(node)
7474
return self:calculate_icons(node)
7575
end
7676

77-
--- Maybe icons, optionally implemented
77+
---Maybe icons, optionally implemented
7878
---@protected
79-
---@param _ table node
79+
---@param _ Node
8080
---@return HighlightedString[]|nil icons
8181
function Decorator:calculate_icons(_)
8282
return nil
8383
end
8484

85-
--- Maybe highlight group, optionally implemented
85+
---Maybe highlight group, optionally implemented
8686
---@protected
87-
---@param _ table node
87+
---@param _ Node
8888
---@return string|nil group
8989
function Decorator:calculate_highlight(_)
9090
return nil
9191
end
9292

93-
--- Define a sign
93+
---Define a sign
9494
---@protected
9595
---@param icon HighlightedString|nil
9696
function Decorator:define_sign(icon)

lua/nvim-tree/renderer/decorator/modified.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,18 @@ function DecoratorModified:new(opts)
3434
return o
3535
end
3636

37-
--- Modified icon: modified.enable, renderer.icons.show.modified and node is modified
37+
---Modified icon: modified.enable, renderer.icons.show.modified and node is modified
38+
---@param node Node
39+
---@return HighlightedString[]|nil icons
3840
function DecoratorModified:calculate_icons(node)
3941
if self.enabled and buffers.is_modified(node) then
4042
return { self.icon }
4143
end
4244
end
4345

44-
--- Modified highlight: modified.enable, renderer.highlight_modified and node is modified
46+
---Modified highlight: modified.enable, renderer.highlight_modified and node is modified
47+
---@param node Node
48+
---@return string|nil group
4549
function DecoratorModified:calculate_highlight(node)
4650
if not self.enabled or self.hl_pos == HL_POSITION.none or not buffers.is_modified(node) then
4751
return nil

lua/nvim-tree/renderer/decorator/opened.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ function DecoratorOpened:new(opts)
2323
return o
2424
end
2525

26-
--- Opened highlight: renderer.highlight_opened_files and node has an open buffer
27-
---@param node table
26+
---Opened highlight: renderer.highlight_opened_files and node has an open buffer
27+
---@param node Node
28+
---@return string|nil group
2829
function DecoratorOpened:calculate_highlight(node)
2930
if self.hl_pos ~= HL_POSITION.none and buffers.is_opened(node) then
3031
return "NvimTreeOpenedHL"

0 commit comments

Comments
 (0)