Skip to content

Commit ba296e6

Browse files
committed
feat(#2948): document API
1 parent 6148f69 commit ba296e6

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

lua/nvim-tree/_meta/api_decorator.lua

+23-17
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ error("Cannot require a meta file")
33

44
local nvim_tree = { api = { decorator = { AbstractDecorator = {} } } }
55

6-
---Custom decorator extends nvim_tree.api.decorator.AbstractDecorator
6+
---Custom decorator
77
---It may:
88
--- Add icons
9-
--- Set name highlight group
9+
--- Set highlight group for the name or icons
1010
--- Override node icon
1111
---Class must be created via nvim_tree.api.decorator.create()
1212
---Mandatory constructor :new() will be called once per tree render, with no arguments.
@@ -24,46 +24,52 @@ local nvim_tree = { api = { decorator = { AbstractDecorator = {} } } }
2424
---Names of predefined decorators or your decorator classes
2525
---@alias nvim_tree.api.decorator.Name "Cut" | "Copied" | "Diagnostics" | "Bookmarks" | "Modified" | "Hidden" | "Opened" | "Git" | nvim_tree.api.decorator.AbstractDecorator
2626

27-
---Abstract decorator class, your decorator will extend this
27+
---Abstract decorator class, your decorator will extend this.
2828
---
2929
---@class (exact) nvim_tree.api.decorator.AbstractDecorator
3030
---@field protected enabled boolean
3131
---@field protected highlight_range nvim_tree.api.decorator.HighlightRange
3232
---@field protected icon_placement nvim_tree.api.decorator.IconPlacement
3333

34-
---Abstract no-args constructor must be implemented
34+
---Abstract: no-args constructor must be implemented.
3535
---
3636
function nvim_tree.api.decorator.AbstractDecorator:new() end
3737

38-
---Must be called from your constructor
39-
---
40-
---@class (exact) nvim_tree.api.decorator.AbstractDecoratorInitArgs
41-
---@field enabled boolean
42-
---@field highlight_range nvim_tree.api.decorator.HighlightRange
43-
---@field icon_placement nvim_tree.api.decorator.IconPlacement
44-
---
45-
---@protected
46-
---@param args nvim_tree.api.decorator.AbstractDecoratorInitArgs
47-
function nvim_tree.api.decorator.AbstractDecorator:init(args) end
48-
4938
---Abstract: optionally implement to set the node's icon
5039
---
5140
---@param node nvim_tree.api.Node
5241
---@return HighlightedString? icon_node
5342
function nvim_tree.api.decorator.AbstractDecorator:icon_node(node) end
5443

55-
---Abstract: optionally implement to provide icons and the highlight groups for your icon_placement
44+
---Abstract: optionally implement to provide icons and the highlight groups for your icon_placement.
5645
---
5746
---@param node nvim_tree.api.Node
5847
---@return HighlightedString[]? icons
5948
function nvim_tree.api.decorator.AbstractDecorator:icons(node) end
6049

61-
---Abstract: optionally implement to provide one highlight group to apply to your highlight_range
50+
---Abstract: optionally implement to provide one highlight group to apply to your highlight_range.
6251
---
6352
---@param node nvim_tree.api.Node
6453
---@return string? highlight_group
6554
function nvim_tree.api.decorator.AbstractDecorator:highlight_group(node) end
6655

56+
---Must be called from your constructor.
57+
---
58+
---@class (exact) nvim_tree.api.decorator.AbstractDecoratorInitArgs
59+
---@field enabled boolean
60+
---@field highlight_range nvim_tree.api.decorator.HighlightRange
61+
---@field icon_placement nvim_tree.api.decorator.IconPlacement
62+
---
63+
---@protected
64+
---@param args nvim_tree.api.decorator.AbstractDecoratorInitArgs
65+
function nvim_tree.api.decorator.AbstractDecorator:init(args) end
66+
67+
---Define a sign. This should be called in the constructor.
68+
---
69+
---@protected
70+
---@param icon HighlightedString?
71+
function nvim_tree.api.decorator.AbstractDecorator:define_sign(icon) end
72+
6773

6874
--
6975
-- Example Decorator

0 commit comments

Comments
 (0)