@@ -6,6 +6,7 @@ local view = require("nvim-tree.view")
6
6
local watch = require (" nvim-tree.explorer.watch" )
7
7
local explorer_node = require (" nvim-tree.explorer.node" )
8
8
9
+ local BaseNode = require (" nvim-tree.node" )
9
10
local DirectoryNode = require (" nvim-tree.node.directory" )
10
11
local FileNode = require (" nvim-tree.node.file" )
11
12
local LinkNode = require (" nvim-tree.node.link" )
@@ -25,7 +26,7 @@ local FILTER_REASON = require("nvim-tree.enum").FILTER_REASON
25
26
26
27
local config
27
28
28
- --- @class Explorer
29
+ --- @class Explorer : BaseNode
29
30
--- @field opts table user options
30
31
--- @field absolute_path string
31
32
--- @field nodes Node[]
@@ -37,7 +38,7 @@ local config
37
38
--- @field sorters Sorter
38
39
--- @field marks Marks
39
40
--- @field clipboard Clipboard
40
- local Explorer = {}
41
+ local Explorer = BaseNode : new ()
41
42
42
43
--- @param path string | nil
43
44
--- @return Explorer | nil
84
85
85
86
function Explorer :destroy ()
86
87
local function iterate (node )
87
- explorer_node . node_destroy ( node )
88
+ node : destroy ( )
88
89
if node .nodes then
89
90
for _ , child in pairs (node .nodes ) do
90
91
iterate (child )
@@ -114,7 +115,7 @@ function Explorer:reload(node, git_status)
114
115
115
116
local remain_childs = {}
116
117
117
- local node_ignored = explorer_node . is_git_ignored (node )
118
+ local node_ignored = node : is_git_ignored ()
118
119
--- @type table<string , Node>
119
120
local nodes_by_path = utils .key_by (node .nodes , " absolute_path" )
120
121
@@ -150,7 +151,7 @@ function Explorer:reload(node, git_status)
150
151
151
152
if n .type ~= t then
152
153
utils .array_remove (node .nodes , n )
153
- explorer_node . node_destroy ( n )
154
+ n : destroy ( )
154
155
nodes_by_path [abs ] = nil
155
156
end
156
157
end
@@ -193,14 +194,14 @@ function Explorer:reload(node, git_status)
193
194
if remain_childs [n .absolute_path ] then
194
195
return remain_childs [n .absolute_path ]
195
196
else
196
- explorer_node . node_destroy ( n )
197
+ n : destroy ( )
197
198
return false
198
199
end
199
200
end , node .nodes )
200
201
)
201
202
202
203
local is_root = not node .parent
203
- local child_folder_only = explorer_node . has_one_child_folder (node ) and node .nodes [1 ]
204
+ local child_folder_only = node : has_one_child_folder () and node .nodes [1 ]
204
205
if config .renderer .group_empty and not is_root and child_folder_only then
205
206
node .group_next = child_folder_only
206
207
local ns = self :reload (child_folder_only , git_status )
@@ -329,7 +330,7 @@ function Explorer:update_parent_statuses(node, project, root)
329
330
end
330
331
331
332
-- update status
332
- explorer_node .update_git_status (node , explorer_node . is_git_ignored ( node .parent ), project )
333
+ explorer_node .update_git_status (node , node . parent and node .parent : is_git_ignored ( ), project )
333
334
334
335
-- maybe parent
335
336
node = node .parent
343
344
--- @param git_status table
344
345
--- @param parent Explorer
345
346
function Explorer :populate_children (handle , cwd , node , git_status , parent )
346
- local node_ignored = explorer_node . is_git_ignored (node )
347
+ local node_ignored = node : is_git_ignored ()
347
348
local nodes_by_path = utils .bool_record (node .nodes , " absolute_path" )
348
349
349
350
local filter_status = parent .filters :prepare (git_status )
@@ -419,7 +420,7 @@ function Explorer:explore(node, status, parent)
419
420
self :populate_children (handle , cwd , node , status , parent )
420
421
421
422
local is_root = not node .parent
422
- local child_folder_only = explorer_node . has_one_child_folder (node ) and node .nodes [1 ]
423
+ local child_folder_only = node : has_one_child_folder () and node .nodes [1 ]
423
424
if config .renderer .group_empty and not is_root and child_folder_only then
424
425
local child_cwd = child_folder_only .link_to or child_folder_only .absolute_path
425
426
local child_status = git .load_project_status (child_cwd )
0 commit comments