feat: support collapse a single folder under cursor#2847
feat: support collapse a single folder under cursor#2847linepi wants to merge 1 commit intonvim-tree:masterfrom
Conversation
|
There might be some imperfections in the naming, documentation, and code details. What I am presenting here is just a rough idea. If this pull request idea is accepted, I will continue to work hard to make more reasonable, reliable, and complete revisions. |
I think I migh not understand what you mean. |
|
@evertonse No, that is not the same. |
Ah I see now, then there should be |
|
I update my commit, including the command, doc and explanation. Please review. |
alex-courtis
left a comment
There was a problem hiding this comment.
Apologies for not seeing this one earlier...
This is great, we should have had this long ago. I'm thinking about a free default keybinding we can use.
We will do this this however:
- It's missing the
keep_buffersparameter ofcollapse_all collapse.luarepeatscollapse-all.luataking a node instead of usingexplorer
Please an optional node parameter to collapse-all.fn so that it may perform both and keep buffers.
doc/nvim-tree-lua.txt
Outdated
| Parameters: ~ | ||
| • {keep_buffers} (boolean) do not collapse nodes with open buffers. | ||
|
|
||
| tree.collapse() *nvim-tree-api.tree.collapse()* |
There was a problem hiding this comment.
| tree.collapse() *nvim-tree-api.tree.collapse()* | |
| tree.collapse() *nvim-tree-api.tree.collapse()* |
spacing
|
This is great, many thanks for pushing this one. |
All right, I've added and option to |
|
On It looks like we're changing API from a boolean to an opts table. We'll need to provide backwards compatibility for legacy arguments, similar to Alternative: add an API method TL;DR point 2 was asking to use a single collapse function rather than a single API. |
tree.collapse_all({keep_buffers}) *nvim-tree-api.tree.collapse_all()*
Collapse the entire tree.
Parameters: ~
• {keep_buffers} (boolean) do not collapse nodes with open buffers.
tree.collapse({opts}) *nvim-tree-api.tree.collapse()*
Collapse the tree.
Parameters: ~
• {opts} (table) optional parameters
Options: ~
• {under_cursor} (boolean) only collapse the node under cursor,
default false
• {keep_buffers} (boolean) do not collapse nodes with open buffers,
default falseThis preserves backward compatibility and the API can stay pure, something like: Api.tree.collapse = wrap(actions.tree.modifiers.collapse_all.collapse)
Api.tree.collapse_all = wrap(actions.tree.modifiers.collapse_all.collapse_all)
---@param keep_buffers boolean
function M.fn(keep_buffers)
M.collapse({keep_buffers = keep_buffers, under_cursor = false})
endFinally, rename |
alex-courtis
left a comment
There was a problem hiding this comment.
Looking good, we are close...
|
Closing as this PR is stale. Please reopen if you wish to continue this work. |
|
picked it up in #3140 |
When I use
api.tree.expand_allto expand a folder, sometimes I need to collapse a single folder rather than all folders(invoke byapi.tree.collapse_all). This feature(api.tree.collapse) can be understood as the inverse operation ofapi.tree.expand_all.