You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
---Highlighting and icons for nodes are provided by Decorators, see [nvim-tree-icons-highlighting]. You may provide your own in addition to the builtin decorators.
4
+
---Highlighting and icons for nodes are provided by Decorators, see [nvim-tree-icons-highlighting] for an overview. You may provide your own in addition to the builtin decorators.
5
+
---
6
+
---Decorators are rendered in [nvim_tree.config.renderer] {decorators} order of precedence, with later decorators applying additively over earlier.
5
7
---
6
8
---Decorators may:
7
9
---- Add icons
8
-
---- Set highlight group for the name or icons
10
+
---- Set a highlight group name for the name or icons
9
11
---- Override node icon
10
12
---
11
13
---To register your decorator:
12
14
---- Create a class that extends [nvim_tree.api.Decorator]
13
15
---- Register it by adding the class to [nvim_tree.config.renderer] {decorators}
14
16
---
17
+
---Your decorator will be constructed and executed each time the tree is rendered.
18
+
---
15
19
---Your class must:
16
-
---- [nvim_tree.Class:extend()] the interface [nvim_tree.api.Decorator]
20
+
---- [nvim_tree.Class:extend()] the interface [nvim_tree.api.Decorator]
17
21
---- Provide a no-arguments constructor [nvim_tree.Class:new()] that sets the mandatory fields:
18
22
--- - {enabled}
19
23
--- - {highlight_range}
20
24
--- - {icon_placement}
25
+
---- Call [nvim_tree.api.Decorator:define_sign()] in your constructor when {icon_placement} is `"signcolumn"`
21
26
---
22
27
---Your class may:
23
28
---- Implement methods to provide decorations:
24
29
--- - [nvim_tree.api.Decorator:highlight_group()]
25
30
--- - [nvim_tree.api.Decorator:icon_node()]
26
31
--- - [nvim_tree.api.Decorator:icons()]
27
-
---
28
-
---Your class must:
29
-
---- Call [nvim_tree.api.Decorator:define_sign()] in your constructor if using `"signcolumn"` {icon_placement}
30
32
31
33
localnvim_tree= { api= {} }
32
34
33
35
localClass=require("nvim-tree.classic")
34
36
35
37
---
36
-
---Highlight group range as per nvim-tree.renderer.highlight_*
---@returnnvim_tree.api.decorator.highlighted_string[]?icons`nil` or empty table for no icons. Only the first glyph of {str} is used when {icon_placement} is `"signcolumn"`
78
90
functionDecorator:icons(node) end
79
91
80
92
---
81
-
---Abstract: optionally implement to provide one highlight group to apply to your highlight_range.
93
+
---One highlight group that applies additively to the {node} name for {highlight_range}.
94
+
---
95
+
---Abstract, optional to implement.
82
96
---
83
97
---@paramnodenvim_tree.api.Node
84
-
---@returnstring?highlight_group
98
+
---@returnstring?highlight group name `nil` when no highlighting to apply to the node
85
99
functionDecorator:highlight_group(node) end
86
100
87
101
---
88
-
---Defines a sign. This should be called in the constructor.
102
+
---Defines a sign for an icon. This is mandatory and necessary only when {icon_placement} is `"signcolumn"`
103
+
---
104
+
---This must be called during your constructor for all icons that you will return from [nvim_tree.api.Decorator:icons()]
0 commit comments