* 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
@@ -1,5 +1,4 @@
|
||||
local notify = require("nvim-tree.notify")
|
||||
local explorer_node = require("nvim-tree.explorer.node")
|
||||
|
||||
local HL_POSITION = require("nvim-tree.enum").HL_POSITION
|
||||
local ICON_PLACEMENT = require("nvim-tree.enum").ICON_PLACEMENT
|
||||
@@ -10,23 +9,25 @@ local Decorator = require("nvim-tree.renderer.decorator")
|
||||
---@field ord number decreasing priority
|
||||
|
||||
---@class (exact) DecoratorGit: Decorator
|
||||
---@field file_hl table<string, string> by porcelain status e.g. "AM"
|
||||
---@field folder_hl table<string, string> by porcelain status
|
||||
---@field icons_by_status HighlightedStringGit[] by human status
|
||||
---@field icons_by_xy table<string, HighlightedStringGit[]> by porcelain status
|
||||
---@field file_hl table<string, string>? by porcelain status e.g. "AM"
|
||||
---@field folder_hl table<string, string>? by porcelain status
|
||||
---@field icons_by_status HighlightedStringGit[]? by human status
|
||||
---@field icons_by_xy table<string, HighlightedStringGit[]>? by porcelain status
|
||||
local DecoratorGit = Decorator:new()
|
||||
|
||||
---Static factory method
|
||||
---@param opts table
|
||||
---@param explorer Explorer
|
||||
---@return DecoratorGit
|
||||
function DecoratorGit:new(opts, explorer)
|
||||
local o = Decorator.new(self, {
|
||||
function DecoratorGit:create(opts, explorer)
|
||||
---@type DecoratorGit
|
||||
local o = {
|
||||
explorer = explorer,
|
||||
enabled = opts.git.enable,
|
||||
hl_pos = HL_POSITION[opts.renderer.highlight_git] or HL_POSITION.none,
|
||||
icon_placement = ICON_PLACEMENT[opts.renderer.icons.git_placement] or ICON_PLACEMENT.none,
|
||||
})
|
||||
---@cast o DecoratorGit
|
||||
}
|
||||
o = self:new(o) --[[@as DecoratorGit]]
|
||||
|
||||
if not o.enabled then
|
||||
return o
|
||||
@@ -147,7 +148,7 @@ function DecoratorGit:calculate_icons(node)
|
||||
return nil
|
||||
end
|
||||
|
||||
local git_status = explorer_node.get_git_status(node)
|
||||
local git_status = node:get_git_status()
|
||||
if git_status == nil then
|
||||
return nil
|
||||
end
|
||||
@@ -208,7 +209,7 @@ function DecoratorGit:calculate_highlight(node)
|
||||
return nil
|
||||
end
|
||||
|
||||
local git_status = explorer_node.get_git_status(node)
|
||||
local git_status = node:get_git_status()
|
||||
if not git_status then
|
||||
return nil
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user