Skip to content

Commit c34b042

Browse files
committed
chore: complete lua doc
1 parent f31c01b commit c34b042

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

lua/nvim-tree/api.lua

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,21 @@ local Api = {
4242
}
4343

4444
--- Print error when setup not called.
45-
--- f function to invoke
46-
---@param f function
47-
---@return fun(...) : any
48-
local function wrap(f)
45+
---@param fn fun(...)
46+
---@return fun(...)
47+
local function wrap(fn)
4948
return function(...)
5049
if vim.g.NvimTreeSetup == 1 then
51-
return f(...)
50+
return fn(...)
5251
else
5352
notify.error("nvim-tree setup not called")
5453
end
5554
end
5655
end
5756

5857
---Inject the node as the first argument if present otherwise do nothing.
59-
---@param fn function function to invoke
58+
---@param fn fun(node: Node, ...)
59+
---@return fun(node: Node, ...)
6060
local function wrap_node(fn)
6161
return function(node, ...)
6262
node = node or lib.get_node_at_cursor()
@@ -67,7 +67,8 @@ local function wrap_node(fn)
6767
end
6868

6969
---Inject the node or nil as the first argument if absent.
70-
---@param fn function function to invoke
70+
---@param fn fun(node: Node, ...)
71+
---@return fun(node: Node, ...)
7172
local function wrap_node_or_nil(fn)
7273
return function(node, ...)
7374
node = node or lib.get_node_at_cursor()
@@ -211,6 +212,7 @@ local function edit(mode, node)
211212
end
212213

213214
---@param mode string
215+
---@param toggle_group boolean?
214216
---@return fun(node: Node)
215217
local function open_or_expand_or_dir_up(mode, toggle_group)
216218
---@param node Node
@@ -286,7 +288,7 @@ Api.config.mappings.default_on_attach = keymap.default_on_attach
286288
Api.diagnostics.hi_test = wrap(appearance_diagnostics.hi_test)
287289

288290
Api.commands.get = wrap(function()
289-
return require("nvim-tree.commands").get()
291+
require("nvim-tree.commands").get()
290292
end)
291293

292294
return Api

lua/nvim-tree/explorer/sorters.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ end
1717

1818
--- Predefined comparator, defaulting to name
1919
---@param sorter string as per options
20-
---@return function
20+
---@return fun(a: Node, b: Node): boolean
2121
function Sorter:get_comparator(sorter)
2222
return function(a, b)
2323
return (C[sorter] or C.name)(a, b, self.config)

lua/nvim-tree/keymap.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
local M = {}
22

33
--- Apply mappings to a scratch buffer and return buffer local mappings
4-
---@param fn function(bufnr) on_attach or default_on_attach
4+
---@param fn fun(bufnr: integer) on_attach or default_on_attach
55
---@return table as per vim.api.nvim_buf_get_keymap
66
local function generate_keymap(fn)
77
-- create an unlisted scratch buffer

0 commit comments

Comments
 (0)