Skip to content

Commit 3ab3980

Browse files
committed
feat(#2948): document API
1 parent 8b5f342 commit 3ab3980

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

lua/nvim-tree/_meta/api_decorator.lua

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---@meta
22
error("Cannot require a meta file")
33

4-
local nvim_tree = { api = { decorator = { BaseDecorator = {} } } }
4+
local nvim_tree = { api = { decorator = { AbstractDecorator = {} } } }
55

6-
---Custom decorator extends nvim_tree.api.decorator.BaseDecorator
6+
---Custom decorator extends nvim_tree.api.decorator.AbstractDecorator
77
---It may:
88
--- Add icons
99
--- Set name highlight group
@@ -21,60 +21,60 @@ local nvim_tree = { api = { decorator = { BaseDecorator = {} } } }
2121
---@alias nvim_tree.api.decorator.IconPlacement "none" | "before" | "after" | "signcolumn" | "right_align"
2222

2323
---Names of predefined decorators or your decorator classes
24-
---@alias nvim_tree.api.decorator.Name "Cut" | "Copied" | "Diagnostics" | "Bookmarks" | "Modified" | "Hidden" | "Opened" | "Git" | nvim_tree.api.decorator.BaseDecorator
24+
---@alias nvim_tree.api.decorator.Name "Cut" | "Copied" | "Diagnostics" | "Bookmarks" | "Modified" | "Hidden" | "Opened" | "Git" | nvim_tree.api.decorator.AbstractDecorator
2525

26-
---BaseDecorator Class, your decorator will extend this
26+
---Abstract decorator class, your decorator will extend this
2727
---
28-
---@class (exact) nvim_tree.api.decorator.BaseDecorator
28+
---@class (exact) nvim_tree.api.decorator.AbstractDecorator
2929
---@field protected enabled boolean
3030
---@field protected highlight_range nvim_tree.api.decorator.HighlightRange
3131
---@field protected icon_placement nvim_tree.api.decorator.IconPlacement
3232

33-
---No-args constructor must be implemented
33+
---Abstract no-args constructor must be implemented
3434
---
35-
function nvim_tree.api.decorator.BaseDecorator:new() end
35+
function nvim_tree.api.decorator.AbstractDecorator:new() end
3636

3737
---Must be called from your constructor
3838
---
39-
---@class (exact) nvim_tree.api.decorator.InitArgs
39+
---@class (exact) nvim_tree.api.decorator.AbstractDecoratorInitArgs
4040
---@field enabled boolean
4141
---@field highlight_range nvim_tree.api.decorator.HighlightRange
4242
---@field icon_placement nvim_tree.api.decorator.IconPlacement
4343
---
4444
---@protected
45-
---@param args nvim_tree.api.decorator.InitArgs
46-
function nvim_tree.api.decorator.BaseDecorator:init(args) end
45+
---@param args nvim_tree.api.decorator.AbstractDecoratorInitArgs
46+
function nvim_tree.api.decorator.AbstractDecorator:init(args) end
4747

48-
---Optionally implement this method to set the node's icon
48+
---Abstract: optionally implement to set the node's icon
4949
---
5050
---@param node nvim_tree.api.Node
5151
---@return HighlightedString? icon_node
52-
function nvim_tree.api.decorator.BaseDecorator:icon_node(node) end
52+
function nvim_tree.api.decorator.AbstractDecorator:icon_node(node) end
5353

54-
---Optionally implement this method to provide icons and the highlight groups for your icon_placement
54+
---Abstract: optionally implement to provide icons and the highlight groups for your icon_placement
5555
---
5656
---@param node nvim_tree.api.Node
5757
---@return HighlightedString[]? icons
58-
function nvim_tree.api.decorator.BaseDecorator:icons(node) end
58+
function nvim_tree.api.decorator.AbstractDecorator:icons(node) end
5959

60-
---Optionally implement this method to provide one highlight group to apply to your highlight_range
60+
---Abstract: optionally implement to provide one highlight group to apply to your highlight_range
6161
---
6262
---@param node nvim_tree.api.Node
6363
---@return string? highlight_group
64-
function nvim_tree.api.decorator.BaseDecorator:highlight_group(node) end
64+
function nvim_tree.api.decorator.AbstractDecorator:highlight_group(node) end
6565

6666

6767
--
6868
-- Example Decorator
6969
--
7070

71-
---@class (exact) MyDecorator: nvim_tree.api.decorator.BaseDecorator
71+
---@class (exact) MyDecorator: nvim_tree.api.decorator.AbstractDecorator
7272
---@field private my_icon nvim_tree.api.HighlightedString
7373
local MyDecorator = require("nvim-tree.api").decorator.create()
7474

7575
---Mandatory constructor :new() will be called once per tree render, with no arguments.
7676
function MyDecorator:new()
77-
---@type nvim_tree.api.decorator.InitArgs
77+
---@type nvim_tree.api.decorator.AbstractDecoratorInitArgs
7878
local args = {
7979
enabled = true,
8080
highlight_range = "all",

lua/nvim-tree/api.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,13 +316,13 @@ end)
316316

317317
---Create a new decorator class
318318
---
319-
---@return nvim_tree.api.decorator.BaseDecorator
319+
---@return nvim_tree.api.decorator.AbstractDecorator
320320
Api.decorator.create = function() return DecoratorUser:extend() end
321321

322322
---Register a decorator class
323323
---
324324
---@class RegisterOpts
325-
---@field decorator nvim_tree.api.decorator.BaseDecorator
325+
---@field decorator nvim_tree.api.decorator.AbstractDecorator
326326
---@field below nvim_tree.api.decorator.Name?
327327
---
328328
---@param opts RegisterOpts
@@ -331,7 +331,7 @@ Api.decorator.register = function(opts) decorator_registry.register(opts) end
331331
---Unregister a decorator class
332332
---
333333
---@class UnRegisterOpts
334-
---@field decorator nvim_tree.api.decorator.BaseDecorator
334+
---@field decorator nvim_tree.api.decorator.AbstractDecorator
335335
---
336336
---@param opts UnRegisterOpts
337337
Api.decorator.unregister = function(opts) decorator_registry.unregister(opts) end

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
local Decorator = require("nvim-tree.renderer.decorator")
22

3-
---Exposed as nvim_tree.api.decorator.BaseDecorator
3+
---Exposed as nvim_tree.api.decorator.AbstractDecorator
44
---@class (exact) DecoratorUser: Decorator
55
local DecoratorUser = Decorator:extend()
66

77
---User calls this instead of new
8-
---@param args nvim_tree.api.decorator.InitArgs
8+
---@param args nvim_tree.api.decorator.AbstractDecoratorInitArgs
99
function DecoratorUser:init(args)
1010
DecoratorUser.super.new(self, args)
1111
end

0 commit comments

Comments
 (0)