-
-
Notifications
You must be signed in to change notification settings - Fork 627
feat: add actions.open_file.eject #2341
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested ok, works as advertised.
quit_on_open
behaviour is now correctly documented.
lua/nvim-tree.lua
Outdated
end | ||
end, | ||
}) | ||
if opts.actions.open_file.prevent_buffer_override then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this inside the callback, to allow users to change this option with a subsequent setup call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
doc/nvim-tree-lua.txt
Outdated
@@ -494,6 +494,7 @@ applying configuration. | |||
}, | |||
open_file = { | |||
quit_on_open = false, | |||
prevent_buffer_override = true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
buffer_override is used internally, however it's not a very clear description.
Perhaps we could call this eject_buffer
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's a better name. Maybe also eject_tree
to highlight the nvim-tree buffer is ejected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
false indicates "do nothing" i.e. don't interfere with normal vim behaviour. We never really do anything with the tree itself.
Since this is under open_file
we could just call it open_file.eject
. Your description is quite accurate, describing what happens to the new buffer.
I do get quite critical when it comes to option names / places. It's easy to get right when adding but very hard to refactor later...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree naming things that you cannot change later should be discussed vigorously :) I will rename to open_file.eject
Rebased with nvim-tree master |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many thanks for your changes!
There have been many discussions in the past around such behaviour and this should have a wide impact.
Hello!
In issue #1628 and PR #1637 the following expected behavior was introduced. When opening a file using
:edit
(or Telescope) while being focused on nvim-tree window, the new file opens in another window (and, depending onquit_on_open
option, the nvim-tree window either stays or closes). This is useful when using nvim-tree in "expected" way, i.e. as a narrow column window on the side, which can be toggled on and off.However, I'd like to use nvim-tree as a replacement of netrw: I would mostly want to open files from the tree in-place, overriding the tree window. While there already exists an API function
api.node.open.replace_tree_buffer
which performs an in-place open, issuing:e
or using Telescope does not make the desired in-place open.This PR adds an option
nvim-tree.actions.open_file.eject
, which istrue
by default (current behavior). When it'sfalse
, it disables nvim-tree hijacking of such in-place opens: the new file will be opened in the same window, replacing nvim-tree.Please provide feedback, whether this option would be useful (or whether there is already another way to achieve the desired effect). Thank you