Skip to content

Commit 5a2e128

Browse files
committed
docs(#3241): namespace decorator types
1 parent c90ac64 commit 5a2e128

File tree

16 files changed

+42
-43
lines changed

16 files changed

+42
-43
lines changed

lua/nvim-tree/_meta/config/renderer.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ error("Cannot require a meta file")
6161
---(default: `true`)
6262
---@field symlink_destination? boolean
6363
---
64-
---TODO #3241 add an alias for builtins
6564
---(default: `{ "Git", "Open", "Hidden", "Modified", "Bookmark", "Diagnostics", "Copied", "Cut", }`)
6665
---@field decorators? (string|nvim_tree.api.decorator.UserDecorator)[]
6766
---

lua/nvim-tree/api.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ local api = {
101101
require("nvim-tree.api.impl.pre")(api)
102102

103103

104-
---#TODO 3241
105-
---Public API classes
106-
-- api.decorator = require("nvim-tree.api.decorator")
104+
--#TODO 3241
105+
--Public API classes
106+
--api.decorator = require("nvim-tree.api.decorator")
107107

108108

109109
return api

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 HighlightedString name
41+
---@return nvim_tree.api.decorator.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 HighlightedString name
61+
---@return nvim_tree.api.decorator.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 HighlightedString icon
201+
---@return nvim_tree.api.decorator.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 HighlightedString icon
246+
---@return nvim_tree.api.decorator.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 HighlightedString icon
34+
---@return nvim_tree.api.decorator.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 HighlightedString name
49+
---@return nvim_tree.api.decorator.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 HighlightedString icon
53+
---@return nvim_tree.api.decorator.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 HighlightedString name
82+
---@return nvim_tree.api.decorator.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 HighlightedString icon
96+
---@return nvim_tree.api.decorator.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 HighlightedString icon
103+
---@return nvim_tree.api.decorator.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 HighlightedString name
110+
---@return nvim_tree.api.decorator.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 HighlightedString name
117+
---@return nvim_tree.api.decorator.highlighted_string name
118118
function Node:highlighted_name()
119119
return self:highlighted_name_empty()
120120
end

lua/nvim-tree/renderer/builder.lua

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ local UserDecorator = require("nvim-tree.api").decorator.UserDecorator
1818

1919
local pad = require("nvim-tree.renderer.components.padding")
2020

21-
---@alias HighlightedString nvim_tree.api.decorator.highlighted_string
21+
---TODO #3241 add an alias for builtins or document the enum
2222

2323
-- Builtin Decorators
2424
---@type table<nvim_tree.api.decorator.types, Decorator>
@@ -106,7 +106,7 @@ function Builder:insert_highlight(groups, start, end_)
106106
end
107107

108108
---@private
109-
---@param highlighted_strings HighlightedString[]
109+
---@param highlighted_strings nvim_tree.api.decorator.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 HighlightedString[]
130-
---@param arrows HighlightedString[]|nil
131-
---@param icon HighlightedString
132-
---@param name HighlightedString
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
133133
---@param node table
134-
---@return HighlightedString[]
134+
---@return nvim_tree.api.decorator.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)
@@ -231,8 +231,8 @@ end
231231
---A highlight group is always calculated and upserted for the case of highlights changing.
232232
---@private
233233
---@param node Node
234-
---@return HighlightedString icon
235-
---@return HighlightedString name
234+
---@return nvim_tree.api.decorator.highlighted_string icon
235+
---@return nvim_tree.api.decorator.highlighted_string name
236236
function Builder:icon_name_decorated(node)
237237
-- use the api node for user decorators
238238
local api_node = self.api_nodes and self.api_nodes[node.uid_node] --[[@as Node]]

lua/nvim-tree/renderer/components/padding.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ end
6464
---@param node Node
6565
---@param markers table
6666
---@param early_stop integer?
67-
---@return HighlightedString
67+
---@return nvim_tree.api.decorator.highlighted_string
6868
function M.get_indent_markers(depth, idx, nodes_number, node, markers, early_stop)
6969
local str = ""
7070

@@ -83,7 +83,7 @@ function M.get_indent_markers(depth, idx, nodes_number, node, markers, early_sto
8383
end
8484

8585
---@param node Node
86-
---@return HighlightedString[]|nil
86+
---@return nvim_tree.api.decorator.highlighted_string[]?
8787
function M.get_arrows(node)
8888
if not M.config.icons.show.folder_arrow then
8989
return

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

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

33
---@class (exact) BookmarkDecorator: Decorator
44
---@field private explorer Explorer
5-
---@field private icon HighlightedString?
5+
---@field private icon nvim_tree.api.decorator.highlighted_string?
66
local BookmarkDecorator = Decorator:extend()
77

88
---@class BookmarkDecorator
@@ -28,7 +28,7 @@ end
2828

2929
---Bookmark icon: renderer.icons.show.bookmarks and node is marked
3030
---@param node Node
31-
---@return HighlightedString[]? icons
31+
---@return nvim_tree.api.decorator.highlighted_string[]? icons
3232
function BookmarkDecorator:icons(node)
3333
if self.explorer.marks:get(node) then
3434
return { self.icon }

0 commit comments

Comments
 (0)