@@ -3,6 +3,7 @@ local renderer = require "nvim-tree.renderer"
3
3
local Iterator = require " nvim-tree.iterators.node-iterator"
4
4
local notify = require " nvim-tree.notify"
5
5
local lib = require " nvim-tree.lib"
6
+ local git = require " nvim-tree.git"
6
7
7
8
local M = {}
8
9
@@ -18,18 +19,28 @@ local function to_lookup_table(list)
18
19
end
19
20
20
21
--- @param node Node
21
- local function expand (node )
22
- node = lib .get_last_group_node (node )
23
- node .open = true
22
+ local function populate_node (node )
23
+ -- noop if it is a file
24
+ if node .nodes == nil then
25
+ return
26
+ end
27
+ local cwd = node .link_to or node .absolute_path
28
+ local handle = vim .loop .fs_scandir (cwd )
29
+ if not handle then
30
+ return
31
+ end
32
+ local status = git .load_project_status (cwd )
33
+
24
34
if # node .nodes == 0 then
25
- core .get_explorer ():expand (node )
35
+ core .get_explorer ():expand (node , status )
26
36
end
27
37
end
28
38
29
39
--- @param expansion_count integer
30
40
--- @param node Node
41
+ --- @param populate_node function
31
42
--- @return boolean , function
32
- local function expand_until_max_or_empty (expansion_count , node )
43
+ local function expand_until_max_or_empty (expansion_count , node , populate_node )
33
44
local should_halt = expansion_count >= M .MAX_FOLDER_DISCOVERY
34
45
local should_exclude = M .EXCLUDE [node .name ]
35
46
local result = not should_halt and node .nodes and not node .open and not should_exclude
@@ -40,16 +51,17 @@ local function gen_iterator(should_expand_fn)
40
51
local expansion_count = 0
41
52
42
53
return function (parent )
43
- expand ( parent )
54
+ parent . open = true
44
55
45
- Iterator .builder ({parent })
56
+ Iterator .builder ({ parent })
46
57
:hidden ()
47
58
:applier (function (node )
48
- local should_expand , should_expand_next_fn = should_expand_fn (expansion_count , node )
59
+ local should_expand , should_expand_next_fn = should_expand_fn (expansion_count , node , populate_node )
49
60
should_expand_fn = should_expand_next_fn
50
61
if should_expand then
51
62
expansion_count = expansion_count + 1
52
- expand (node )
63
+ node = lib .get_last_group_node (node )
64
+ node .open = true
53
65
end
54
66
end )
55
67
:recursor (function (node )
0 commit comments