* add todo * refactor(#2886): multi instance: node class refactoring: extract links, *_git_status (#2944) * extract DirectoryLinkNode and FileLinkNode, move Node methods to children * temporarily move DirectoryNode methods into BaseNode for easier reviewing * move mostly unchanged DirectoryNode methods back to BaseNode * tidy * git.git_status_file takes an array * update git status of links * luacheck hack * safer git_status_dir * refactor(#2886): multi instance: node class refactoring: DirectoryNode:expand_or_collapse (#2957) move expand_or_collapse to DirectoryNode * refactor(#2886): multi instance: node group functions refactoring (#2959) * move last_group_node to DirectoryNode * move add BaseNode:as and more doc * revert parameter name changes * revert parameter name changes * add Class * move group methods into DN * tidy group methods * tidy group methods * tidy group methods * tidy group methods * parent is DirectoryNode * tidy expand all * BaseNode -> Node * move watcher to DirectoryNode * last_group_node is DirectoryNode only * simplify create-file * simplify parent * simplify collapse-all * simplify live-filter * style * move lib.get_cursor_position to Explorer * move lib.get_node_at_cursor to Explorer * move lib.get_nodes to Explorer * move place_cursor_on_node to Explorer * resolve resource leak in purge_all_state * move many autocommands into Explorer * post merge tidy
This commit is contained in:
committed by
GitHub
parent
8760d76c1d
commit
f3efc25e56
@@ -1,6 +1,5 @@
|
||||
local view = require("nvim-tree.view")
|
||||
local core = require("nvim-tree.core")
|
||||
local utils = require("nvim-tree.utils")
|
||||
local events = require("nvim-tree.events")
|
||||
local notify = require("nvim-tree.notify")
|
||||
|
||||
@@ -13,48 +12,6 @@ local M = {
|
||||
target_winid = nil,
|
||||
}
|
||||
|
||||
---Cursor position as per vim.api.nvim_win_get_cursor
|
||||
---nil on no explorer or invalid view win
|
||||
---@return integer[]|nil
|
||||
function M.get_cursor_position()
|
||||
if not core.get_explorer() then
|
||||
return
|
||||
end
|
||||
|
||||
local winnr = view.get_winnr()
|
||||
if not winnr or not vim.api.nvim_win_is_valid(winnr) then
|
||||
return
|
||||
end
|
||||
|
||||
return vim.api.nvim_win_get_cursor(winnr)
|
||||
end
|
||||
|
||||
---@return Node|nil
|
||||
function M.get_node_at_cursor()
|
||||
local explorer = core.get_explorer()
|
||||
if not explorer then
|
||||
return
|
||||
end
|
||||
|
||||
local cursor = M.get_cursor_position()
|
||||
if not cursor then
|
||||
return
|
||||
end
|
||||
|
||||
if cursor[1] == 1 and view.is_root_folder_visible(core.get_cwd()) then
|
||||
return explorer
|
||||
end
|
||||
|
||||
return utils.get_nodes_by_line(explorer.nodes, core.get_nodes_starting_line())[cursor[1]]
|
||||
end
|
||||
|
||||
---Api.tree.get_nodes
|
||||
---@return Node[]?
|
||||
function M.get_nodes()
|
||||
local explorer = core.get_explorer()
|
||||
return explorer and explorer:clone()
|
||||
end
|
||||
|
||||
function M.set_target_win()
|
||||
local id = vim.api.nvim_get_current_win()
|
||||
local tree_id = view.get_winnr()
|
||||
|
||||
Reference in New Issue
Block a user