Skip to content

Commit d1ababb

Browse files
feat: add float quit_on_focus_loss+quit_on_open support
1 parent 7282f7d commit d1ababb

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

doc/nvim-tree-lua.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,9 +698,13 @@ Window / buffer setup.
698698
Configuration options for floating window
699699

700700
*nvim-tree.view.float.enable*
701-
Display nvim-tree window as float (enforces |nvim-tree.actions.open_file.quit_on_open| if set).
701+
Display nvim-tree window as float (enforces if set).
702702
Type: `boolean`, Default: `false`
703703

704+
*nvim-tree.view.float.quit_on_focus_loss
705+
When in floating mode, autoclose the popup when the popup loses the focus.
706+
Type: `boolean`, Default: `true`
707+
704708
*nvim-tree.view.float.open_win_config*
705709
Floating window config. See |nvim_open_win| for more details.
706710
Type: `table` or `function` that returns a table, Default:

lua/nvim-tree.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ local function setup_autocommands(opts)
418418
})
419419
end
420420

421-
if opts.view.float.enable then
421+
if opts.view.float.enable and opts.view.float.quit_on_focus_loss then
422422
create_nvim_tree_autocmd("WinLeave", { pattern = "NvimTree_*", callback = view.close })
423423
end
424424
end
@@ -463,6 +463,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
463463
},
464464
float = {
465465
enable = false,
466+
quit_on_focus_loss = true,
466467
open_win_config = {
467468
relative = "editor",
468469
border = "rounded",

lua/nvim-tree/actions/node/open-file.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ function M.fn(mode, filename)
267267
end
268268

269269
function M.setup(opts)
270-
M.quit_on_open = opts.actions.open_file.quit_on_open or opts.view.float.enable
270+
M.quit_on_open = opts.actions.open_file.quit_on_open
271271
M.resize_window = opts.actions.open_file.resize_window
272272
if opts.actions.open_file.window_picker.chars then
273273
opts.actions.open_file.window_picker.chars = tostring(opts.actions.open_file.window_picker.chars):upper()

0 commit comments

Comments
 (0)