Skip to content

Commit 4bd30f0

Browse files
authored
feat: add actions.open_file.eject (#2341)
* feat: added prevent_buffer_override option to allow in-place opens by :e * Moved option check inside the callback * Renamed option to eject
1 parent 75c0574 commit 4bd30f0

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

doc/nvim-tree-lua.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,7 @@ applying configuration.
494494
},
495495
open_file = {
496496
quit_on_open = false,
497+
eject = true,
497498
resize_window = true,
498499
window_picker = {
499500
enable = true,
@@ -1203,9 +1204,12 @@ Configuration for various actions.
12031204

12041205
*nvim-tree.actions.open_file.quit_on_open*
12051206
Closes the explorer when opening a file.
1206-
It will also disable preventing a buffer overriding the tree.
12071207
Type: `boolean`, Default: `false`
12081208

1209+
*nvim-tree.actions.open_file.eject*
1210+
Prevent new opened file from opening in the same window as the tree.
1211+
Type: `boolean`, Default: `true`
1212+
12091213
*nvim-tree.actions.open_file.resize_window* (previously `view.auto_resize`)
12101214
Resizes the tree when opening a file.
12111215
Type: `boolean`, Default: `true`

lua/nvim-tree.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ local function setup_autocommands(opts)
196196
create_nvim_tree_autocmd("BufWipeout", {
197197
pattern = "NvimTree_*",
198198
callback = function()
199-
if utils.is_nvim_tree_buf(0) then
199+
if utils.is_nvim_tree_buf(0) and opts.actions.open_file.eject then
200200
view._prevent_buffer_override()
201201
end
202202
end,
@@ -545,6 +545,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
545545
},
546546
open_file = {
547547
quit_on_open = false,
548+
eject = true,
548549
resize_window = true,
549550
window_picker = {
550551
enable = true,

0 commit comments

Comments
 (0)