* chore: add type annotations to (almost) all functions
* stylua
* Add classes for symlink nodes
* Replace deprecated `@vararg`
* Move node classes to `node` module
* Fix `Symlink*` classes
* add vim and libuv runtime for luals, qualify libuv types
* add scripts/luals-check, not quite ready for CI
* additional nil checks for git/init.lua and git/runner.lua
* additional nil checks for nvim-tree.lua
* wrap vim.cmd-as-a-function calls inside functions
* vim.tbl_filter predicate returns booleans
* Revert "add scripts/luals-check, not quite ready for CI"
This reverts commit c70229cad9.
* Add `MinimalNode` class in `marks` module
* Fix various LSP warnings
* stylua
* Fix `Explorer` class, update related annotations and add necessary checks
* Add missing annotations to `live-filter`
* Add temporary aliases for `uv.*` types
* Resolve remaining LSP warnings
* Revert changes not related to internal types
* Minor adjustments
* Update doc comments style
* Minor adjustments (pt. 2)
---------
Co-authored-by: Alexander Courtis <alex@courtis.org>
40 lines
947 B
Lua
40 lines
947 B
Lua
local renderer = require "nvim-tree.renderer"
|
|
local view = require "nvim-tree.view"
|
|
local utils = require "nvim-tree.utils"
|
|
local core = require "nvim-tree.core"
|
|
local lib = require "nvim-tree.lib"
|
|
|
|
local M = {}
|
|
|
|
---@param should_close boolean|nil
|
|
---@return fun(node: Node): boolean|nil
|
|
function M.fn(should_close)
|
|
should_close = should_close or false
|
|
|
|
return function(node)
|
|
node = lib.get_last_group_node(node)
|
|
if should_close and node.open then
|
|
node.open = false
|
|
return renderer.draw()
|
|
end
|
|
|
|
local parent = utils.get_parent_of_group(node).parent
|
|
|
|
if not parent or not parent.parent then
|
|
return view.set_cursor { 1, 0 }
|
|
end
|
|
|
|
local _, line = utils.find_node(core.get_explorer().nodes, function(n)
|
|
return n.absolute_path == parent.absolute_path
|
|
end)
|
|
|
|
view.set_cursor { line + 1, 0 }
|
|
if should_close then
|
|
parent.open = false
|
|
renderer.draw()
|
|
end
|
|
end
|
|
end
|
|
|
|
return M
|