File tree Expand file tree Collapse file tree 4 files changed +14
-12
lines changed Expand file tree Collapse file tree 4 files changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -23,12 +23,8 @@ local function buf_match()
23
23
end
24
24
end
25
25
26
- --- @param opts ApiTreeCollapseOpts | nil
27
- function M .fn (opts )
28
- opts = opts or {}
29
- local keep_buffers = opts .keep_buffers or false
30
- local under_cursor = opts .under_cursor or false
31
-
26
+ --- @param opts ApiTreeCollapseOpts
27
+ function M .collapse (opts )
32
28
local explorer = core .get_explorer ()
33
29
if not explorer then
34
30
return
@@ -42,7 +38,7 @@ function M.fn(opts)
42
38
local matches = buf_match ()
43
39
44
40
local selected_nodes
45
- if under_cursor then
41
+ if opts . under_cursor then
46
42
if not node or not node .nodes then
47
43
return
48
44
end
@@ -56,7 +52,7 @@ function M.fn(opts)
56
52
:applier (function (n )
57
53
local dir = n :as (DirectoryNode )
58
54
if dir then
59
- dir .open = keep_buffers and matches (dir .absolute_path )
55
+ dir .open = opts . keep_buffers and matches (dir .absolute_path )
60
56
end
61
57
end )
62
58
:recursor (function (n )
@@ -68,4 +64,9 @@ function M.fn(opts)
68
64
utils .focus_node_or_parent (node )
69
65
end
70
66
67
+ --- @param keep_buffers boolean
68
+ function M .collapse_all (keep_buffers )
69
+ M .collapse ({ keep_buffers = keep_buffers , under_cursor = false })
70
+ end
71
+
71
72
return M
Original file line number Diff line number Diff line change 1
1
local M = {}
2
2
3
- M .collapse_all = require (" nvim-tree.actions.tree.modifiers.collapse-all " )
3
+ M .collapse = require (" nvim-tree.actions.tree.modifiers.collapse" )
4
4
M .expand_all = require (" nvim-tree.actions.tree.modifiers.expand-all" )
5
5
6
6
function M .setup (opts )
Original file line number Diff line number Diff line change @@ -187,7 +187,8 @@ Api.tree.search_node = wrap(actions.finders.search_node.fn)
187
187
--- @field under_cursor boolean
188
188
--- @field keep_buffers boolean
189
189
190
- Api .tree .collapse_all = wrap (actions .tree .modifiers .collapse_all .fn )
190
+ Api .tree .collapse = wrap (actions .tree .modifiers .collapse .collapse )
191
+ Api .tree .collapse_all = wrap (actions .tree .modifiers .collapse .collapse_all )
191
192
Api .tree .expand_all = wrap_node (actions .tree .modifiers .expand_all .fn )
192
193
Api .tree .toggle_enable_filters = wrap_explorer_member (" filters" , " toggle" )
193
194
Api .tree .toggle_gitignore_filter = wrap_explorer_member_args (" filters" , " toggle" , " git_ignored" )
Original file line number Diff line number Diff line change @@ -121,7 +121,7 @@ local CMDS = {
121
121
bar = true ,
122
122
},
123
123
command = function ()
124
- api .tree .collapse_all ({ under_cursor = false , keep_buffers = false })
124
+ api .tree .collapse ({ under_cursor = false , keep_buffers = false })
125
125
end ,
126
126
},
127
127
{
@@ -131,7 +131,7 @@ local CMDS = {
131
131
bar = true ,
132
132
},
133
133
command = function ()
134
- api .tree .collapse_all ({ under_cursor = true , keep_buffers = false })
134
+ api .tree .collapse ({ under_cursor = true , keep_buffers = false })
135
135
end ,
136
136
},
137
137
{
You can’t perform that action at this time.
0 commit comments