|
1 | 1 | ---@meta |
2 | | -error("Cannot require a meta file") |
3 | | - |
| 2 | +--- |
4 | 3 | local nvim_tree = { api = { decorator = {} } } |
5 | 4 |
|
| 5 | +local Class = require("nvim-tree.classic") |
| 6 | + |
6 | 7 | ---Highlight group range as per nvim-tree.renderer.highlight_* |
7 | 8 | ---@alias nvim_tree.api.decorator.highlight_range nvim_tree.config.renderer.highlight |
8 | 9 |
|
9 | 10 | ---Icon position as per renderer.icons.*_placement |
10 | 11 | ---@alias nvim_tree.api.decorator.icon_placement "none"|nvim_tree.config.renderer.icons.placement |
11 | 12 |
|
12 | 13 | ---Names of builtin decorators or your decorator classes. Builtins are ordered lowest to highest priority. |
13 | | ----@alias nvim_tree.api.decorator.types nvim_tree.api.decorator.UserDecorator|"Git"|"Opened"|"Hidden"|"Modified"|"Bookmarks"|"Diagnostics"|"Copied"|"Cut" |
| 14 | +---@alias nvim_tree.api.decorator.types nvim_tree.api.decorator.Decorator|"Git"|"Opened"|"Hidden"|"Modified"|"Bookmarks"|"Diagnostics"|"Copied"|"Cut" |
14 | 15 |
|
15 | 16 | ---A string for rendering, with optional highlight groups to apply to it |
16 | 17 | ---@class (exact) nvim_tree.api.decorator.highlighted_string |
17 | 18 | ---@field str string |
18 | 19 | ---@field hl string[] |
19 | 20 |
|
20 | | ----Custom decorator, see :help nvim-tree-decorators |
| 21 | +---Abstract Decorator interface |
21 | 22 | --- |
22 | | ----@class (exact) nvim_tree.api.decorator.UserDecorator |
| 23 | +---@class (exact) nvim_tree.api.decorator.Decorator: Class |
23 | 24 | ---@field protected enabled boolean |
24 | 25 | ---@field protected highlight_range nvim_tree.api.decorator.highlight_range |
25 | 26 | ---@field protected icon_placement nvim_tree.api.decorator.icon_placement |
26 | | -nvim_tree.api.decorator.UserDecorator = {} |
27 | | - |
28 | | ----Create your decorator class |
29 | | ---- |
30 | | -function nvim_tree.api.decorator.UserDecorator:extend() end |
31 | | - |
32 | | ----Abstract: no-args constructor must be implemented and will be called once per tree render. |
33 | | ----Must set all fields. |
34 | | ---- |
35 | | -function nvim_tree.api.decorator.UserDecorator:new() end |
| 27 | +nvim_tree.api.decorator.Decorator = Class:extend() |
36 | 28 |
|
37 | 29 | ---Abstract: optionally implement to set the node's icon |
38 | 30 | --- |
39 | 31 | ---@param node nvim_tree.api.Node |
40 | 32 | ---@return nvim_tree.api.decorator.highlighted_string? icon_node |
41 | | -function nvim_tree.api.decorator.UserDecorator:icon_node(node) end |
| 33 | +function nvim_tree.api.decorator.Decorator:icon_node(node) end |
42 | 34 |
|
43 | 35 | ---Abstract: optionally implement to provide icons and the highlight groups for your icon_placement. |
44 | 36 | --- |
45 | 37 | ---@param node nvim_tree.api.Node |
46 | 38 | ---@return nvim_tree.api.decorator.highlighted_string[]? icons |
47 | | -function nvim_tree.api.decorator.UserDecorator:icons(node) end |
| 39 | +function nvim_tree.api.decorator.Decorator:icons(node) end |
48 | 40 |
|
49 | 41 | ---Abstract: optionally implement to provide one highlight group to apply to your highlight_range. |
50 | 42 | --- |
51 | 43 | ---@param node nvim_tree.api.Node |
52 | 44 | ---@return string? highlight_group |
53 | | -function nvim_tree.api.decorator.UserDecorator:highlight_group(node) end |
| 45 | +function nvim_tree.api.decorator.Decorator:highlight_group(node) end |
54 | 46 |
|
55 | | ----Define a sign. This should be called in the constructor. |
| 47 | +---Defines a sign. This should be called in the constructor. |
56 | 48 | --- |
57 | 49 | ---@protected |
58 | 50 | ---@param icon nvim_tree.api.decorator.highlighted_string? |
59 | | -function nvim_tree.api.decorator.UserDecorator:define_sign(icon) end |
| 51 | +function nvim_tree.api.decorator.Decorator:define_sign(icon) end |
| 52 | + |
| 53 | +---@deprecated use `nvim_tree.api.decorator.Decorator` |
| 54 | +---@class nvim_tree.api.decorator.UserDecorator: nvim_tree.api.decorator.Decorator |
| 55 | +nvim_tree.api.decorator.UserDecorator = nvim_tree.api.decorator.Decorator |
| 56 | + |
| 57 | +return nvim_tree.api.decorator |
0 commit comments