Skip to content

Commit 077af9f

Browse files
authored
chore: enable incomplete-signature-doc, format nvt-min.lua, assorted formatting tidies (#2967)
* chore: luacheckrc uses table * chore: format nvt-min.lua * chore: complete lua doc * chore: complete lua doc * chore: complete lua doc * chore: complete lua doc * chore: complete lua doc * chore: enable incomplete-signature-doc * chore: enable incomplete-signature-doc * chore: complete lua doc * chore: complete lua doc
1 parent 68be6df commit 077af9f

File tree

17 files changed

+54
-33
lines changed

17 files changed

+54
-33
lines changed

Diff for: .github/ISSUE_TEMPLATE/nvt-min.lua

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
vim.g.loaded_netrw = 1
22
vim.g.loaded_netrwPlugin = 1
33

4-
vim.cmd [[set runtimepath=$VIMRUNTIME]]
5-
vim.cmd [[set packpath=/tmp/nvt-min/site]]
4+
vim.cmd([[set runtimepath=$VIMRUNTIME]])
5+
vim.cmd([[set packpath=/tmp/nvt-min/site]])
66
local package_root = "/tmp/nvt-min/site/pack"
77
local install_path = package_root .. "/packer/start/packer.nvim"
88
local function load_plugins()
9-
require("packer").startup {
9+
require("packer").startup({
1010
{
1111
"wbthomason/packer.nvim",
1212
"nvim-tree/nvim-tree.lua",
@@ -18,21 +18,21 @@ local function load_plugins()
1818
compile_path = install_path .. "/plugin/packer_compiled.lua",
1919
display = { non_interactive = true },
2020
},
21-
}
21+
})
2222
end
2323
if vim.fn.isdirectory(install_path) == 0 then
24-
print "Installing nvim-tree and dependencies."
25-
vim.fn.system { "git", "clone", "--depth=1", "https://github.com/wbthomason/packer.nvim", install_path }
24+
print("Installing nvim-tree and dependencies.")
25+
vim.fn.system({ "git", "clone", "--depth=1", "https://github.com/wbthomason/packer.nvim", install_path })
2626
end
2727
load_plugins()
2828
require("packer").sync()
29-
vim.cmd [[autocmd User PackerComplete ++once echo "Ready!" | lua setup()]]
29+
vim.cmd([[autocmd User PackerComplete ++once echo "Ready!" | lua setup()]])
3030
vim.opt.termguicolors = true
3131
vim.opt.cursorline = true
3232

3333
-- MODIFY NVIM-TREE SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
3434
_G.setup = function()
35-
require("nvim-tree").setup {}
35+
require("nvim-tree").setup({})
3636
end
3737

3838
-- UNCOMMENT this block for diagnostics issues, substituting pattern and cmd as appropriate.

Diff for: .luacheckrc

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
-- vim: ft=lua tw=80
1+
local M = {}
22

33
-- Don't report unused self arguments of methods.
4-
self = false
4+
M.self = false
55

6-
ignore = {
6+
M.ignore = {
77
"631", -- max_line_length
88
}
99

1010
-- Global objects defined by the C code
11-
globals = {
11+
M.globals = {
1212
"vim",
13-
"TreeExplorer"
1413
}
14+
15+
return M

Diff for: .luarc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"empty-block": "Any",
3434
"global-element": "Any",
3535
"global-in-nil-env": "Any",
36-
"incomplete-signature-doc": "None",
36+
"incomplete-signature-doc": "Any",
3737
"inject-field": "Any",
3838
"invisible": "Any",
3939
"lowercase-global": "Any",

Diff for: lua/nvim-tree/actions/moves/parent.lua

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ function M.fn(should_close)
2525
local parent = (node:get_parent_of_group() or node).parent
2626

2727
if not parent or not parent.parent then
28-
return view.set_cursor({ 1, 0 })
28+
view.set_cursor({ 1, 0 })
29+
return
2930
end
3031

3132
local _, line = utils.find_node(parent.explorer.nodes, function(n)

Diff for: lua/nvim-tree/actions/node/open-file.lua

+1
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ end
369369

370370
---@param mode string
371371
---@param filename string
372+
---@return nil
372373
function M.fn(mode, filename)
373374
if type(mode) ~= "string" then
374375
mode = ""

Diff for: lua/nvim-tree/actions/tree/modifiers/expand-all.lua

+10-6
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,18 @@ end
3030
---@param node Node
3131
---@return boolean
3232
local function should_expand(expansion_count, node)
33+
local dir = node:as(DirectoryNode)
34+
if not dir then
35+
return false
36+
end
3337
local should_halt = expansion_count >= M.MAX_FOLDER_DISCOVERY
34-
local should_exclude = M.EXCLUDE[node.name]
35-
return not should_halt and node.nodes and not node.open and not should_exclude
38+
local should_exclude = M.EXCLUDE[dir.name]
39+
return not should_halt and not dir.open and not should_exclude
3640
end
3741

3842
local function gen_iterator()
3943
local expansion_count = 0
4044

41-
---@param parent DirectoryNode
4245
return function(parent)
4346
if parent.parent and parent.nodes and not parent.open then
4447
expansion_count = expansion_count + 1
@@ -47,14 +50,15 @@ local function gen_iterator()
4750

4851
Iterator.builder(parent.nodes)
4952
:hidden()
50-
---@param node DirectoryNode
5153
:applier(function(node)
5254
if should_expand(expansion_count, node) then
5355
expansion_count = expansion_count + 1
54-
expand(node)
56+
node = node:as(DirectoryNode)
57+
if node then
58+
expand(node)
59+
end
5560
end
5661
end)
57-
---@param node DirectoryNode
5862
:recursor(function(node)
5963
return expansion_count < M.MAX_FOLDER_DISCOVERY and (node.group_next and { node.group_next } or (node.open and node.nodes))
6064
end)

Diff for: lua/nvim-tree/api.lua

+11-9
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(...): any
46+
---@return fun(...): any
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, ...): any
59+
---@return fun(node: Node, ...): any
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, ...): any
71+
---@return fun(node: Node, ...): any
7172
local function wrap_node_or_nil(fn)
7273
return function(node, ...)
7374
node = node or lib.get_node_at_cursor()
@@ -78,7 +79,7 @@ end
7879
---Invoke a method on the singleton explorer.
7980
---Print error when setup not called.
8081
---@param explorer_method string explorer method name
81-
---@return fun(...) : any
82+
---@return fun(...): any
8283
local function wrap_explorer(explorer_method)
8384
return wrap(function(...)
8485
local explorer = core.get_explorer()
@@ -92,7 +93,7 @@ end
9293
---Print error when setup not called.
9394
---@param explorer_member string explorer member name
9495
---@param member_method string method name to invoke on member
95-
---@return fun(...) : any
96+
---@return fun(...): any
9697
local function wrap_explorer_member(explorer_member, member_method)
9798
return wrap(function(...)
9899
local explorer = core.get_explorer()
@@ -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

Diff for: lua/nvim-tree/explorer/filters.lua

+2
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,11 @@ local function dotfile(self, path)
107107
return self.config.filter_dotfiles and utils.path_basename(path):sub(1, 1) == "."
108108
end
109109

110+
---Bookmark is present
110111
---@param path string
111112
---@param path_type string|nil filetype of path
112113
---@param bookmarks table<string, string|nil> path, filetype table of bookmarked files
114+
---@return boolean
113115
local function bookmark(self, path, path_type, bookmarks)
114116
if not self.config.filter_no_bookmark then
115117
return false

Diff for: lua/nvim-tree/explorer/init.lua

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ end
8080

8181
---@param node DirectoryNode
8282
---@param git_status table|nil
83+
---@return Node[]?
8384
function Explorer:reload(node, git_status)
8485
local cwd = node.link_to or node.absolute_path
8586
local handle = vim.loop.fs_scandir(cwd)

Diff for: lua/nvim-tree/explorer/live-filter.lua

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ local LiveFilter = {}
1313

1414
---@param opts table
1515
---@param explorer Explorer
16+
---@return LiveFilter
1617
function LiveFilter:new(opts, explorer)
1718
local o = {
1819
explorer = explorer,

Diff for: lua/nvim-tree/explorer/sorters.lua

+3-1
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)
@@ -41,6 +41,7 @@ end
4141
---Evaluate `sort.folders_first` and `sort.files_first`
4242
---@param a Node
4343
---@param b Node
44+
---@param cfg table
4445
---@return boolean|nil
4546
local function folders_or_files_first(a, b, cfg)
4647
if not (cfg.folders_first or cfg.files_first) then
@@ -164,6 +165,7 @@ end
164165
---@param a Node
165166
---@param b Node
166167
---@param ignorecase boolean|nil
168+
---@param cfg table
167169
---@return boolean
168170
local function node_comparator_name_ignorecase_or_not(a, b, ignorecase, cfg)
169171
if not (a and b) then

Diff for: lua/nvim-tree/help.lua

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ end
5353
--- sort vim command lhs roughly as per :help index
5454
---@param a string
5555
---@param b string
56+
---@return boolean
5657
local function sort_lhs(a, b)
5758
-- mouse first
5859
if a:match(PAT_MOUSE) and not b:match(PAT_MOUSE) then

Diff for: lua/nvim-tree/keymap.lua

+1-1
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

Diff for: lua/nvim-tree/log.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ end
9292
---@param typ string as per log.types config
9393
---@param node Node? node to be inspected
9494
---@param fmt string for string.format
95-
---@vararg any arguments for string.format
95+
---@param ... any arguments for string.format
9696
function M.node(typ, node, fmt, ...)
9797
if M.enabled(typ) then
9898
node = node or require("nvim-tree.lib").get_node_at_cursor()

Diff for: lua/nvim-tree/renderer/components/padding.lua

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ end
6161
---@param nodes_number integer
6262
---@param node Node
6363
---@param markers table
64+
---@param early_stop integer?
6465
---@return HighlightedString[]
6566
function M.get_indent_markers(depth, idx, nodes_number, node, markers, early_stop)
6667
local str = ""

Diff for: lua/nvim-tree/renderer/init.lua

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ end
4141
---@param lines string[]
4242
---@param hl_args AddHighlightArgs[]
4343
---@param signs string[]
44+
---@param extmarks table[] extra marks for right icon placement
45+
---@param virtual_lines table[] virtual lines for hidden count display
4446
function Renderer:_draw(bufnr, lines, hl_args, signs, extmarks, virtual_lines)
4547
if vim.fn.has("nvim-0.10") == 1 then
4648
vim.api.nvim_set_option_value("modifiable", true, { buf = bufnr })

Diff for: lua/nvim-tree/view.lua

+2
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ local function get_size(size)
124124
end
125125

126126
---@param size (fun():integer)|integer|nil
127+
---@return integer
127128
local function get_width(size)
128129
if size then
129130
return get_size(size)
@@ -411,6 +412,7 @@ function M.abandon_all_windows()
411412
end
412413

413414
---@param opts table|nil
415+
---@return boolean
414416
function M.is_visible(opts)
415417
if opts and opts.tabpage then
416418
if M.View.tabpages[opts.tabpage] == nil then

0 commit comments

Comments
 (0)