Skip to content

Commit 7fd4cc8

Browse files
committed
Merge remote-tracking branch 'origin/master' into 2941-move-lib-to-explorer
2 parents 4c9c885 + 8760d76 commit 7fd4cc8

File tree

18 files changed

+74
-37
lines changed

18 files changed

+74
-37
lines changed

.github/ISSUE_TEMPLATE/nvt-min.lua

Lines changed: 8 additions & 8 deletions
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.

.luacheckrc

Lines changed: 6 additions & 5 deletions
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

.luarc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@
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",
4040
"missing-fields": "Any",
4141
"missing-global-doc": "Any",
42-
"missing-local-export-doc": "None",
42+
"missing-local-export-doc": "Any",
4343
"missing-parameter": "Any",
4444
"missing-return": "Any",
4545
"missing-return-value": "Any",

lua/nvim-tree/actions/moves/parent.lua

Lines changed: 2 additions & 1 deletion
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)

lua/nvim-tree/actions/node/open-file.lua

Lines changed: 1 addition & 0 deletions
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 = ""

lua/nvim-tree/actions/tree/modifiers/expand-all.lua

Lines changed: 10 additions & 6 deletions
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)

lua/nvim-tree/api.lua

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,13 @@ local Api = {
4040
diagnostics = {},
4141
}
4242

43-
--- Print error when setup not called.
44-
--- f function to invoke
45-
---@param f function
46-
---@return fun(...) : any
47-
local function wrap(f)
43+
---Print error when setup not called.
44+
---@param fn fun(...): any
45+
---@return fun(...): any
46+
local function wrap(fn)
4847
return function(...)
4948
if vim.g.NvimTreeSetup == 1 then
50-
return f(...)
49+
return fn(...)
5150
else
5251
notify.error("nvim-tree setup not called")
5352
end
@@ -57,7 +56,7 @@ end
5756
---Invoke a method on the singleton explorer.
5857
---Print error when setup not called.
5958
---@param explorer_method string explorer method name
60-
---@return fun(...) : any
59+
---@return fun(...): any
6160
local function wrap_explorer(explorer_method)
6261
return wrap(function(...)
6362
local explorer = core.get_explorer()
@@ -68,7 +67,8 @@ local function wrap_explorer(explorer_method)
6867
end
6968

7069
---Inject the node as the first argument if present otherwise do nothing.
71-
---@param fn function function to invoke
70+
---@param fn fun(node: Node, ...): any
71+
---@return fun(node: Node, ...): any
7272
local function wrap_node(fn)
7373
return function(node, ...)
7474
node = node or wrap_explorer("get_node_at_cursor")()
@@ -79,7 +79,8 @@ local function wrap_node(fn)
7979
end
8080

8181
---Inject the node or nil as the first argument if absent.
82-
---@param fn function function to invoke
82+
---@param fn fun(node: Node, ...): any
83+
---@return fun(node: Node, ...): any
8384
local function wrap_node_or_nil(fn)
8485
return function(node, ...)
8586
node = node or wrap_explorer("get_node_at_cursor")()
@@ -91,7 +92,7 @@ end
9192
---Print error when setup not called.
9293
---@param explorer_member string explorer member name
9394
---@param member_method string method name to invoke on member
94-
---@return fun(...) : any
95+
---@return fun(...): any
9596
local function wrap_explorer_member(explorer_member, member_method)
9697
return wrap(function(...)
9798
local explorer = core.get_explorer()
@@ -210,6 +211,7 @@ local function edit(mode, node)
210211
end
211212

212213
---@param mode string
214+
---@param toggle_group boolean?
213215
---@return fun(node: Node)
214216
local function open_or_expand_or_dir_up(mode, toggle_group)
215217
---@param node Node

lua/nvim-tree/explorer/filters.lua

Lines changed: 2 additions & 0 deletions
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

lua/nvim-tree/explorer/init.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ end
188188

189189
---@param node DirectoryNode
190190
---@param git_status table|nil
191+
---@return Node[]?
191192
function Explorer:reload(node, git_status)
192193
local cwd = node.link_to or node.absolute_path
193194
local handle = vim.loop.fs_scandir(cwd)

lua/nvim-tree/explorer/live-filter.lua

Lines changed: 1 addition & 0 deletions
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,

0 commit comments

Comments
 (0)