-
-
Notifications
You must be signed in to change notification settings - Fork 617
Open a file and keep tree open, but another hotkey for open file and close the tree afterwards #1984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is not currently possible. It could be done via API via a default nil option: {
key = "o",
action = "edit_no_close",
action_cb = function(node)
api.node.open.edit(node, {
close_tree = false,
})
end,
}, |
Thanks for this, I think it would help others. -- Use `o` to open a file
-- Use `<CR>` to open a file and close the tree
local api = require("nvim-tree.api")
local function edit_and_close(node)
api.node.open.edit(node, { close_tree = true, })
api.tree.close()
end
-- { key = "<CR>", action = "edit_and_close", action_cb=edit_and_close }, |
Yes. That has not actually been built. This is a feature request with a suggested action. I'm glad you found something that works in the meantime. |
Yes. Preview buffers are not particularly useful in this case, and not a solution.
This would be useful. Some IDEs have such a feature. |
Indeed. Hopefully it will be implemented in the future. |
Pull requests are gratefully appreciated. |
Hey @alex-courtis , I was looking through this issue and unless I didn't follow it correctly, we could have two new options to the
Does that sound reasonably right to you? If it does, do you think we could tackle both of this in a single PR? I think it makes sense since it would be two options added to the same method |
It's great that we're extending API instead of using more global options; they are out of control.
Sounds good; add the whole new
We might call it
How about just |
Hey @alex-courtis , this sounds good to me - I've created a WIP PR to implement the first option only for now. I've added more details on its first comment. Would you mind having a look to check if you agree with how I did it? If that's fine I'll look into doing a similar thing for the |
One PR or two... whatever works best for you. |
Sorry, I didn't mean about whether to create one or two MRs, but about how I've currently implemented the |
… functions (#3054) * feat: add quit_on_open opt to api.node.open.edit * fix: fix missing @param annotation * feat: add focus opt to api.node.open.edit * fix: fix focus == false behaviour on api.node.open.tab command * fix: add optional tabpage integer parameter to view.close if tabpage is not nil, then the function closes the tabpage in this specific tabpage * fix: fix quit_on_open == true behaviour on api.node.open.tab command * fix: add check to not use new opts for certain edit modes * fix: add docs for new opts --------- Co-authored-by: Alexander Courtis <[email protected]>
Discussed in #1980
Originally posted by mangelozzi February 9, 2023
I found there is an option:
nvim-tree.actions.open_file.quit_on_open
, but the problem with this it always closes the tree afterwards.I wish to have
o
perform as default (keep the tree open after opening the file), but have<CR>
open the buffer and close the tree.Currently these seems to be the only options (tried them all):
edit_in_place
is similar but then I have 2 windows after opening the file, and have to go to the other window and close it.Looking for something like this:
The text was updated successfully, but these errors were encountered: