* refactor(#2875): multi instance renderer * refactor(#2875): multi instance renderer * refactor(#2875): multi instance renderer * refactor(#2875): multi instance renderer * node classes and constructors * node methods * refactor(#2875): multi instance renderer * node classes and constructors * explorer is a directory node * extract methods from explore_node * extract methods from explore_node * extract methods from explore_node * extract methods from lib * use .. name for root node for compatibility * use node.explorer * extract node factory, remove unused code * factories for all nodes, add RootNode * factories for all nodes, add RootNode * use factory pattern for decorators * note regression and commit * fix dir git status regression * destroy nodes, not explorer * add BaseNode:is * revert changes to create-file, handle in #2924 * extract methods from explorer * extract methods from explorer * extract methods from explorer * use Node everywhere in luadoc * extract methods from lib * extract methods from lib * lint * remove unused code * don't call methods on fake root node * get_node_at_cursor returns explorer (root) node instead of { name = '..' } * remove unused inject_node * refactor(#2875): multi instance renderer * refactor(#2875): multi instance renderer * refactor(#2875): multi instance renderer * extract methods from lib * node factory uses stat only * temporary DirectoryNode casting until method extraction into child classes * lua-language-server 3.10.5 -> 3.11.0 * explicitly call Explorer constructor * normalise explorer RootNode new call, tidy annotations
This commit is contained in:
committed by
GitHub
parent
c9104a5d07
commit
38aac09151
@@ -4,7 +4,10 @@ local git_utils = require("nvim-tree.git.utils")
|
||||
local Runner = require("nvim-tree.git.runner")
|
||||
local Watcher = require("nvim-tree.watcher").Watcher
|
||||
local Iterator = require("nvim-tree.iterators.node-iterator")
|
||||
local explorer_node = require("nvim-tree.explorer.node")
|
||||
|
||||
---@class GitStatus
|
||||
---@field file string|nil
|
||||
---@field dir table|nil
|
||||
|
||||
local M = {
|
||||
config = {},
|
||||
@@ -208,18 +211,15 @@ local function reload_tree_at(toplevel)
|
||||
Iterator.builder(root_node.nodes)
|
||||
:hidden()
|
||||
:applier(function(node)
|
||||
local parent_ignored = explorer_node.is_git_ignored(node.parent)
|
||||
explorer_node.update_git_status(node, parent_ignored, git_status)
|
||||
local parent_ignored = node.parent and node.parent:is_git_ignored() or false
|
||||
node:update_git_status(parent_ignored, git_status)
|
||||
end)
|
||||
:recursor(function(node)
|
||||
return node.nodes and #node.nodes > 0 and node.nodes
|
||||
end)
|
||||
:iterate()
|
||||
|
||||
local explorer = require("nvim-tree.core").get_explorer()
|
||||
if explorer then
|
||||
explorer.renderer:draw()
|
||||
end
|
||||
root_node.explorer.renderer:draw()
|
||||
end)
|
||||
end
|
||||
|
||||
@@ -283,6 +283,35 @@ function M.load_project_status(path)
|
||||
end
|
||||
end
|
||||
|
||||
---@param parent_ignored boolean
|
||||
---@param status table|nil
|
||||
---@param absolute_path string
|
||||
---@return GitStatus|nil
|
||||
function M.git_status_dir(parent_ignored, status, absolute_path)
|
||||
if parent_ignored then
|
||||
return { file = "!!" }
|
||||
end
|
||||
|
||||
if status then
|
||||
return {
|
||||
file = status.files and status.files[absolute_path],
|
||||
dir = status.dirs and {
|
||||
direct = status.dirs.direct[absolute_path],
|
||||
indirect = status.dirs.indirect[absolute_path],
|
||||
},
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
---@param parent_ignored boolean
|
||||
---@param status table|nil
|
||||
---@param absolute_path string
|
||||
---@return GitStatus
|
||||
function M.git_status_file(parent_ignored, status, absolute_path)
|
||||
local file_status = parent_ignored and "!!" or (status and status.files and status.files[absolute_path])
|
||||
return { file = file_status }
|
||||
end
|
||||
|
||||
function M.purge_state()
|
||||
log.line("git", "purge_state")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user