diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index 7966be75..0d2f0a35 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -702,9 +702,13 @@ Window / buffer setup. Configuration options for floating window *nvim-tree.view.float.enable* - Display nvim-tree window as float (enforces |nvim-tree.actions.open_file.quit_on_open| if set). + Display nvim-tree window as float (enforces if set). Type: `boolean`, Default: `false` + *nvim-tree.view.float.quit_on_focus_loss + When in floating mode, autoclose the popup when the popup loses the focus. + Type: `boolean`, Default: `true` + *nvim-tree.view.float.open_win_config* Floating window config. See |nvim_open_win| for more details. Type: `table` or `function` that returns a table, Default: diff --git a/lua/nvim-tree.lua b/lua/nvim-tree.lua index 7273eb62..215bcb0f 100644 --- a/lua/nvim-tree.lua +++ b/lua/nvim-tree.lua @@ -412,7 +412,7 @@ local function setup_autocommands(opts) }) end - if opts.view.float.enable then + if opts.view.float.enable and opts.view.float.quit_on_focus_loss then create_nvim_tree_autocmd("WinLeave", { pattern = "NvimTree_*", callback = view.close }) end end @@ -457,6 +457,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS }, float = { enable = false, + quit_on_focus_loss = true, open_win_config = { relative = "editor", border = "rounded", diff --git a/lua/nvim-tree/actions/node/open-file.lua b/lua/nvim-tree/actions/node/open-file.lua index 772ed5cb..33e607bf 100644 --- a/lua/nvim-tree/actions/node/open-file.lua +++ b/lua/nvim-tree/actions/node/open-file.lua @@ -267,7 +267,7 @@ function M.fn(mode, filename) end function M.setup(opts) - M.quit_on_open = opts.actions.open_file.quit_on_open or opts.view.float.enable + M.quit_on_open = opts.actions.open_file.quit_on_open M.resize_window = opts.actions.open_file.resize_window if opts.actions.open_file.window_picker.chars then opts.actions.open_file.window_picker.chars = tostring(opts.actions.open_file.window_picker.chars):upper() diff --git a/lua/nvim-tree/live-filter.lua b/lua/nvim-tree/live-filter.lua index 0dd6eea1..4d8ae7cf 100644 --- a/lua/nvim-tree/live-filter.lua +++ b/lua/nvim-tree/live-filter.lua @@ -25,7 +25,7 @@ local overlay_bufnr = nil local overlay_winnr = nil local function remove_overlay() - if view.View.float.enable then + if view.View.float.enable and view.View.float.quit_on_focus_loss then -- return to normal nvim-tree float behaviour when filter window is closed a.nvim_create_autocmd("WinLeave", { pattern = "NvimTree_*",