File tree Expand file tree Collapse file tree 4 files changed +43
-0
lines changed Expand file tree Collapse file tree 4 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -1770,6 +1770,9 @@ tree.collapse_all({keep_buffers}) *nvim-tree-api.tree.collapse_all()*
1770
1770
Parameters: ~
1771
1771
• {keep_buffers} (boolean) do not collapse nodes with open buffers.
1772
1772
1773
+ tree.collapse() *nvim-tree-api.tree.collapse()*
1774
+ Collapse the folder under cursor.
1775
+
1773
1776
tree.expand_all() *nvim-tree-api.tree.expand_all()*
1774
1777
Recursively expand all nodes in the tree.
1775
1778
Folder: only the nodes underneath that folder.
Original file line number Diff line number Diff line change
1
+ local renderer = require " nvim-tree.renderer"
2
+ local utils = require " nvim-tree.utils"
3
+ local core = require " nvim-tree.core"
4
+ local lib = require " nvim-tree.lib"
5
+ local Iterator = require " nvim-tree.iterators.node-iterator"
6
+
7
+ local M = {}
8
+
9
+ function M .fn ()
10
+ local node = lib .get_node_at_cursor ()
11
+ local explorer = core .get_explorer ()
12
+
13
+ if explorer == nil then
14
+ return
15
+ end
16
+ if node == nil then
17
+ return
18
+ end
19
+ if node .nodes == nil then
20
+ return
21
+ end
22
+
23
+ Iterator .builder (node .nodes )
24
+ :hidden ()
25
+ :applier (function (n )
26
+ n .open = false
27
+ end )
28
+ :recursor (function (n )
29
+ return n .group_next and { n .group_next } or n .nodes
30
+ end )
31
+ :iterate ()
32
+
33
+ node .open = false
34
+ renderer .draw ()
35
+ utils .focus_node_or_parent (node )
36
+ end
37
+
38
+ return M
Original file line number Diff line number Diff line change 1
1
local M = {}
2
2
3
3
M .collapse_all = require " nvim-tree.actions.tree.modifiers.collapse-all"
4
+ M .collapse = require " nvim-tree.actions.tree.modifiers.collapse"
4
5
M .expand_all = require " nvim-tree.actions.tree.modifiers.expand-all"
5
6
M .toggles = require " nvim-tree.actions.tree.modifiers.toggles"
6
7
Original file line number Diff line number Diff line change @@ -161,6 +161,7 @@ Api.tree.get_nodes = wrap(lib.get_nodes)
161
161
Api .tree .find_file = wrap (actions .tree .find_file .fn )
162
162
Api .tree .search_node = wrap (actions .finders .search_node .fn )
163
163
Api .tree .collapse_all = wrap (actions .tree .modifiers .collapse_all .fn )
164
+ Api .tree .collapse = wrap (actions .tree .modifiers .collapse .fn )
164
165
Api .tree .expand_all = wrap_node (actions .tree .modifiers .expand_all .fn )
165
166
Api .tree .toggle_enable_filters = wrap (actions .tree .modifiers .toggles .enable )
166
167
Api .tree .toggle_gitignore_filter = wrap (actions .tree .modifiers .toggles .git_ignored )
You can’t perform that action at this time.
0 commit comments