Skip to content

Commit 958feb0

Browse files
committed
docs(#3241): use general nvim_tree.api.highlighted_string
1 parent 7275609 commit 958feb0

File tree

18 files changed

+132
-132
lines changed

18 files changed

+132
-132
lines changed

doc/nvim-tree-lua.txt

Lines changed: 72 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -902,9 +902,9 @@ Require and register it during |nvim-tree-setup|:
902902
Contents of `my-decorator.lua`:
903903
>lua
904904
---@class (exact) MyDecorator: nvim_tree.api.Decorator
905-
---@field private my_icon1 nvim_tree.api.decorator.highlighted_string
906-
---@field private my_icon2 nvim_tree.api.decorator.highlighted_string
907-
---@field private my_icon_node nvim_tree.api.decorator.highlighted_string
905+
---@field private my_icon1 nvim_tree.api.highlighted_string
906+
---@field private my_icon2 nvim_tree.api.highlighted_string
907+
---@field private my_icon_node nvim_tree.api.highlighted_string
908908
---@field private my_highlight_group string
909909
local MyDecorator = require("nvim-tree.api").Decorator:extend()
910910

@@ -928,7 +928,7 @@ Contents of `my-decorator.lua`:
928928

929929
---Override node icon
930930
---@param node nvim_tree.api.Node
931-
---@return nvim_tree.api.decorator.highlighted_string? icon_node
931+
---@return nvim_tree.api.highlighted_string? icon_node
932932
function MyDecorator:icon_node(node)
933933
if node.name == "example" then
934934
return self.my_icon_node
@@ -939,7 +939,7 @@ Contents of `my-decorator.lua`:
939939

940940
---Return two icons for DecoratorIconPlacement "after"
941941
---@param node nvim_tree.api.Node
942-
---@return nvim_tree.api.decorator.highlighted_string[]? icons
942+
---@return nvim_tree.api.highlighted_string[]? icons
943943
function MyDecorator:icons(node)
944944
if node.name == "example" then
945945
return { self.my_icon1, self.my_icon2, }
@@ -3213,7 +3213,64 @@ winid({opts}) *nvim_tree.api.tree.winid()*
32133213

32143214

32153215
==============================================================================
3216-
API: Decorator *nvim-tree-api-decorator*
3216+
Class *nvim-tree-class*
3217+
3218+
*nvim_tree.Class*
3219+
3220+
Fields: ~
3221+
{super} (`Class`)
3222+
{new} (`fun(self: nvim_tree.Class)`) See
3223+
|nvim_tree.Class:new()|.
3224+
{extend} (`fun(self: nvim_tree.Class)`) See
3225+
|nvim_tree.Class:extend()|.
3226+
{implement} (`fun(self: nvim_tree.Class, mixin: Class)`) See
3227+
|nvim_tree.Class:implement()|.
3228+
{is} (`fun(self: nvim_tree.Class, class: T): boolean`) See
3229+
|nvim_tree.Class:is()|.
3230+
{as} (`fun(self: nvim_tree.Class, class: T): T?`) See
3231+
|nvim_tree.Class:as()|.
3232+
{nop} (`fun(self: nvim_tree.Class, ...: any)`) See
3233+
|nvim_tree.Class:nop()|.
3234+
3235+
3236+
Class:as({class}) *nvim_tree.Class:as()*
3237+
Return object if |nvim_tree.Class:is()| otherwise nil
3238+
3239+
Parameters: ~
3240+
{class} (`any`)
3241+
3242+
Return: ~
3243+
(`T?`)
3244+
3245+
Class:extend() *nvim_tree.Class:extend()*
3246+
Extend a class, setting .super
3247+
3248+
Class:implement({mixin}) *nvim_tree.Class:implement()*
3249+
Implement the functions of a mixin Add the mixin to .implements
3250+
3251+
Parameters: ~
3252+
{mixin} (`Class`)
3253+
3254+
Class:is({class}) *nvim_tree.Class:is()*
3255+
Object is an instance of class or implements a mixin
3256+
3257+
Parameters: ~
3258+
{class} (`any`)
3259+
3260+
Return: ~
3261+
(`boolean`)
3262+
3263+
Class:new() *nvim_tree.Class:new()*
3264+
Default constructor
3265+
3266+
Class:nop({...}) *nvim_tree.Class:nop()*
3267+
3268+
Parameters: ~
3269+
{...} (`any`)
3270+
3271+
3272+
==============================================================================
3273+
Class: Decorator *nvim-tree-class-decorator*
32173274

32183275
Highlighting and icons for nodes are provided by Decorators, see
32193276
|nvim-tree-icons-highlighting| for an overview. You may provide your own in
@@ -3263,16 +3320,16 @@ Your class may:
32633320
• {icon_placement} (`"none"|nvim_tree.config.renderer.icons.placement`)
32643321
Where to place the icons:
32653322
|nvim_tree.config.renderer.icons.placement|
3266-
• {icon_node} (`fun(self: nvim_tree.api.Decorator, node: nvim_tree.api.Node): nvim_tree.api.decorator.highlighted_string?`)
3323+
• {icon_node} (`fun(self: nvim_tree.api.Decorator, node: nvim_tree.api.Node): nvim_tree.api.highlighted_string?`)
32673324
See |nvim_tree.api.Decorator:icon_node()|.
3268-
{icons} (`fun(self: nvim_tree.api.Decorator, node: nvim_tree.api.Node): nvim_tree.api.decorator.highlighted_string[]?`)
3325+
{icons} (`fun(self: nvim_tree.api.Decorator, node: nvim_tree.api.Node): nvim_tree.api.highlighted_string[]?`)
32693326
See |nvim_tree.api.Decorator:icons()|.
32703327
• {highlight_group} (`fun(self: nvim_tree.api.Decorator, node: nvim_tree.api.Node): string?`)
32713328
See |nvim_tree.api.Decorator:highlight_group()|.
3272-
• {define_sign} (`fun(self: nvim_tree.api.Decorator, icon: nvim_tree.api.decorator.highlighted_string?)`)
3329+
• {define_sign} (`fun(self: nvim_tree.api.Decorator, icon: nvim_tree.api.highlighted_string?)`)
32733330
See |nvim_tree.api.Decorator:define_sign()|.
32743331

3275-
*nvim_tree.api.decorator.highlighted_string*
3332+
*nvim_tree.api.highlighted_string*
32763333
Text or glyphs with optional highlight group names to apply to it.
32773334

32783335
Fields: ~
@@ -3289,8 +3346,7 @@ Decorator:define_sign({icon}) *nvim_tree.api.Decorator:define_sign()*
32893346
return from |nvim_tree.api.Decorator:icons()|
32903347

32913348
Parameters: ~
3292-
{icon} (`nvim_tree.api.decorator.highlighted_string?`) does nothing
3293-
if nil
3349+
{icon} (`nvim_tree.api.highlighted_string?`) does nothing if nil
32943350

32953351
*nvim_tree.api.Decorator:highlight_group()*
32963352
Decorator:highlight_group({node})
@@ -3315,8 +3371,7 @@ Decorator:icon_node({node}) *nvim_tree.api.Decorator:icon_node()*
33153371
{node} (`nvim_tree.api.Node`)
33163372

33173373
Return: ~
3318-
(`nvim_tree.api.decorator.highlighted_string?`) icon `nil` for no
3319-
override
3374+
(`nvim_tree.api.highlighted_string?`) icon `nil` for no override
33203375

33213376
Decorator:icons({node}) *nvim_tree.api.Decorator:icons()*
33223377
Icons to add to the node as per {icon_placement}
@@ -3327,66 +3382,9 @@ Decorator:icons({node}) *nvim_tree.api.Decorator:icons()*
33273382
{node} (`nvim_tree.api.Node`)
33283383

33293384
Return: ~
3330-
(`nvim_tree.api.decorator.highlighted_string[]?`) icons `nil` or empty
3331-
table for no icons. Only the first glyph of {str} is used when
3332-
{icon_placement} is `"signcolumn"`
3333-
3334-
3335-
==============================================================================
3336-
API: Class *nvim-tree-api-class*
3337-
3338-
*nvim_tree.Class*
3339-
3340-
Fields: ~
3341-
{super} (`Class`)
3342-
{new} (`fun(self: nvim_tree.Class)`) See
3343-
|nvim_tree.Class:new()|.
3344-
{extend} (`fun(self: nvim_tree.Class)`) See
3345-
|nvim_tree.Class:extend()|.
3346-
{implement} (`fun(self: nvim_tree.Class, mixin: Class)`) See
3347-
|nvim_tree.Class:implement()|.
3348-
{is} (`fun(self: nvim_tree.Class, class: T): boolean`) See
3349-
|nvim_tree.Class:is()|.
3350-
{as} (`fun(self: nvim_tree.Class, class: T): T?`) See
3351-
|nvim_tree.Class:as()|.
3352-
{nop} (`fun(self: nvim_tree.Class, ...: any)`) See
3353-
|nvim_tree.Class:nop()|.
3354-
3355-
3356-
Class:as({class}) *nvim_tree.Class:as()*
3357-
Return object if |nvim_tree.Class:is()| otherwise nil
3358-
3359-
Parameters: ~
3360-
{class} (`any`)
3361-
3362-
Return: ~
3363-
(`T?`)
3364-
3365-
Class:extend() *nvim_tree.Class:extend()*
3366-
Extend a class, setting .super
3367-
3368-
Class:implement({mixin}) *nvim_tree.Class:implement()*
3369-
Implement the functions of a mixin Add the mixin to .implements
3370-
3371-
Parameters: ~
3372-
{mixin} (`Class`)
3373-
3374-
Class:is({class}) *nvim_tree.Class:is()*
3375-
Object is an instance of class or implements a mixin
3376-
3377-
Parameters: ~
3378-
{class} (`any`)
3379-
3380-
Return: ~
3381-
(`boolean`)
3382-
3383-
Class:new() *nvim_tree.Class:new()*
3384-
Default constructor
3385-
3386-
Class:nop({...}) *nvim_tree.Class:nop()*
3387-
3388-
Parameters: ~
3389-
{...} (`any`)
3385+
(`nvim_tree.api.highlighted_string[]?`) icons `nil` or empty table for
3386+
no icons. Only the first glyph of {str} is used when {icon_placement}
3387+
is `"signcolumn"`
33903388

33913389

33923390
vim:tw=78:ts=8:sw=4:sts=4:et:ft=help:norl:

lua/nvim-tree/_meta/api/decorator.lua

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---@meta
22

3+
---#TODO 3241 maybe rename to UserDecorator
4+
35
---@brief
46
---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.
57
---
@@ -37,7 +39,7 @@ local Class = require("nvim-tree.classic")
3739
---
3840
---Text or glyphs with optional highlight group names to apply to it.
3941
---
40-
---@class nvim_tree.api.decorator.highlighted_string
42+
---@class nvim_tree.api.highlighted_string
4143
---
4244
---One or many glyphs/characters.
4345
---@field str string
@@ -69,7 +71,7 @@ nvim_tree.api.Decorator = Decorator
6971
---Abstract, optional to implement.
7072
---
7173
---@param node nvim_tree.api.Node
72-
---@return nvim_tree.api.decorator.highlighted_string? icon `nil` for no override
74+
---@return nvim_tree.api.highlighted_string? icon `nil` for no override
7375
function Decorator:icon_node(node) end
7476

7577
---
@@ -78,7 +80,7 @@ function Decorator:icon_node(node) end
7880
---Abstract, optional to implement.
7981
---
8082
---@param node nvim_tree.api.Node
81-
---@return nvim_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"`
83+
---@return nvim_tree.api.highlighted_string[]? icons `nil` or empty table for no icons. Only the first glyph of {str} is used when {icon_placement} is `"signcolumn"`
8284
function Decorator:icons(node) end
8385

8486
---
@@ -95,7 +97,7 @@ function Decorator:highlight_group(node) end
9597
---
9698
---This must be called during your constructor for all icons that you will return from [nvim_tree.api.Decorator:icons()]
9799
---
98-
---@param icon nvim_tree.api.decorator.highlighted_string? does nothing if nil
100+
---@param icon nvim_tree.api.highlighted_string? does nothing if nil
99101
function Decorator:define_sign(icon) end
100102

101103
return nvim_tree.api.Decorator

lua/nvim-tree/node/directory-link.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function DirectoryLinkNode:update_git_status(parent_ignored, project)
3838
self.git_status = git_utils.git_status_dir(parent_ignored, project, self.link_to, self.absolute_path)
3939
end
4040

41-
---@return nvim_tree.api.decorator.highlighted_string name
41+
---@return nvim_tree.api.highlighted_string name
4242
function DirectoryLinkNode:highlighted_icon()
4343
if not self.explorer.opts.renderer.icons.show.folder then
4444
return self:highlighted_icon_empty()
@@ -58,7 +58,7 @@ function DirectoryLinkNode:highlighted_icon()
5858
end
5959

6060
---Maybe override name with arrow
61-
---@return nvim_tree.api.decorator.highlighted_string name
61+
---@return nvim_tree.api.highlighted_string name
6262
function DirectoryLinkNode:highlighted_name()
6363
local name = DirectoryNode.highlighted_name(self)
6464

lua/nvim-tree/node/directory.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ function DirectoryNode:expand_or_collapse(toggle_group)
198198
self.explorer.renderer:draw()
199199
end
200200

201-
---@return nvim_tree.api.decorator.highlighted_string icon
201+
---@return nvim_tree.api.highlighted_string icon
202202
function DirectoryNode:highlighted_icon()
203203
if not self.explorer.opts.renderer.icons.show.folder then
204204
return self:highlighted_icon_empty()
@@ -243,7 +243,7 @@ function DirectoryNode:highlighted_icon()
243243
return { str = str, hl = { hl } }
244244
end
245245

246-
---@return nvim_tree.api.decorator.highlighted_string icon
246+
---@return nvim_tree.api.highlighted_string icon
247247
function DirectoryNode:highlighted_name()
248248
local str, hl
249249

lua/nvim-tree/node/file-link.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function FileLinkNode:update_git_status(parent_ignored, project)
3131
self.git_status = git_utils.git_status_file(parent_ignored, project, self.link_to, self.absolute_path)
3232
end
3333

34-
---@return nvim_tree.api.decorator.highlighted_string icon
34+
---@return nvim_tree.api.highlighted_string icon
3535
function FileLinkNode:highlighted_icon()
3636
if not self.explorer.opts.renderer.icons.show.file then
3737
return self:highlighted_icon_empty()
@@ -46,7 +46,7 @@ function FileLinkNode:highlighted_icon()
4646
return { str = str, hl = { hl } }
4747
end
4848

49-
---@return nvim_tree.api.decorator.highlighted_string name
49+
---@return nvim_tree.api.highlighted_string name
5050
function FileLinkNode:highlighted_name()
5151
local str = self.name
5252
if self.explorer.opts.renderer.symlink_destination then

lua/nvim-tree/node/file.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function FileNode:get_git_xy()
5050
return self.git_status.file and { self.git_status.file }
5151
end
5252

53-
---@return nvim_tree.api.decorator.highlighted_string icon
53+
---@return nvim_tree.api.highlighted_string icon
5454
function FileNode:highlighted_icon()
5555
if not self.explorer.opts.renderer.icons.show.file then
5656
return self:highlighted_icon_empty()
@@ -79,7 +79,7 @@ function FileNode:highlighted_icon()
7979
return { str = str, hl = { hl } }
8080
end
8181

82-
---@return nvim_tree.api.decorator.highlighted_string name
82+
---@return nvim_tree.api.highlighted_string name
8383
function FileNode:highlighted_name()
8484
local hl
8585
if vim.tbl_contains(self.explorer.opts.renderer.special_files, self.absolute_path) or vim.tbl_contains(self.explorer.opts.renderer.special_files, self.name) then

lua/nvim-tree/node/init.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,28 +93,28 @@ end
9393

9494
---Empty highlighted icon
9595
---@protected
96-
---@return nvim_tree.api.decorator.highlighted_string icon
96+
---@return nvim_tree.api.highlighted_string icon
9797
function Node:highlighted_icon_empty()
9898
return { str = "", hl = {} }
9999
end
100100

101101
---Highlighted icon for the node
102102
---Empty for base Node
103-
---@return nvim_tree.api.decorator.highlighted_string icon
103+
---@return nvim_tree.api.highlighted_string icon
104104
function Node:highlighted_icon()
105105
return self:highlighted_icon_empty()
106106
end
107107

108108
---Empty highlighted name
109109
---@protected
110-
---@return nvim_tree.api.decorator.highlighted_string name
110+
---@return nvim_tree.api.highlighted_string name
111111
function Node:highlighted_name_empty()
112112
return { str = "", hl = {} }
113113
end
114114

115115
---Highlighted name for the node
116116
---Empty for base Node
117-
---@return nvim_tree.api.decorator.highlighted_string name
117+
---@return nvim_tree.api.highlighted_string name
118118
function Node:highlighted_name()
119119
return self:highlighted_name_empty()
120120
end

lua/nvim-tree/renderer/builder.lua

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ function Builder:insert_highlight(groups, start, end_)
106106
end
107107

108108
---@private
109-
---@param highlighted_strings nvim_tree.api.decorator.highlighted_string[]
109+
---@param highlighted_strings nvim_tree.api.highlighted_string[]
110110
---@return string
111111
function Builder:unwrap_highlighted_strings(highlighted_strings)
112112
if not highlighted_strings then
@@ -126,12 +126,12 @@ function Builder:unwrap_highlighted_strings(highlighted_strings)
126126
end
127127

128128
---@private
129-
---@param indent_markers nvim_tree.api.decorator.highlighted_string[]
130-
---@param arrows? nvim_tree.api.decorator.highlighted_string[]
131-
---@param icon nvim_tree.api.decorator.highlighted_string
132-
---@param name nvim_tree.api.decorator.highlighted_string
129+
---@param indent_markers nvim_tree.api.highlighted_string[]
130+
---@param arrows? nvim_tree.api.highlighted_string[]
131+
---@param icon nvim_tree.api.highlighted_string
132+
---@param name nvim_tree.api.highlighted_string
133133
---@param node table
134-
---@return nvim_tree.api.decorator.highlighted_string[]
134+
---@return nvim_tree.api.highlighted_string[]
135135
function Builder:format_line(indent_markers, arrows, icon, name, node)
136136
local added_len = 0
137137
local function add_to_end(t1, t2)
@@ -254,8 +254,8 @@ end
254254
---A highlight group is always calculated and upserted for the case of highlights changing.
255255
---@private
256256
---@param node Node
257-
---@return nvim_tree.api.decorator.highlighted_string icon
258-
---@return nvim_tree.api.decorator.highlighted_string name
257+
---@return nvim_tree.api.highlighted_string icon
258+
---@return nvim_tree.api.highlighted_string name
259259
function Builder:icon_name_decorated(node)
260260
-- use the api node for user decorators
261261
local api_node = self.api_nodes and self.api_nodes[node.uid_node] --[[@as Node]]

0 commit comments

Comments
 (0)