diff --git a/README.md b/README.md index 0f92acb8..35ffc652 100644 --- a/README.md +++ b/README.md @@ -205,6 +205,9 @@ require'nvim-tree'.setup { -- BEGIN_DEFAULT_OPTS }, }, }, + remove_file = { + close_window = true, + }, }, trash = { cmd = "trash", diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index 219add77..2b8a0634 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -223,6 +223,9 @@ Values may be functions. Warning: this may result in unexpected behaviour. }, }, }, + remove_file = { + close_window = true, + }, }, trash = { cmd = "trash", @@ -672,6 +675,10 @@ Configuration for various actions. `buftype = { "nofile", "terminal", "help", }` `}` + *nvim-tree.actions.remove_file.close_window* + Close any window displaying a file when removing the file from the tree. + Type: `boolean`, Default: `true` + *nvim-tree.actions.use_system_clipboard* A boolean value that toggle the use of system clipboard when copy/paste function are invoked. When enabled, copied text will be stored in registers diff --git a/lua/nvim-tree.lua b/lua/nvim-tree.lua index cbffbdac..e63426cc 100644 --- a/lua/nvim-tree.lua +++ b/lua/nvim-tree.lua @@ -480,6 +480,9 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS }, }, }, + remove_file = { + close_window = true, + }, }, trash = { cmd = "trash", diff --git a/lua/nvim-tree/actions/init.lua b/lua/nvim-tree/actions/init.lua index 62d15c4e..1539ccbe 100644 --- a/lua/nvim-tree/actions/init.lua +++ b/lua/nvim-tree/actions/init.lua @@ -237,6 +237,7 @@ function M.setup(opts) require("nvim-tree.actions.trash").setup(opts.trash) require("nvim-tree.actions.open-file").setup(opts) require("nvim-tree.actions.change-dir").setup(opts) + require("nvim-tree.actions.remove-file").setup(opts) require("nvim-tree.actions.copy-paste").setup(opts) require("nvim-tree.actions.create-file").setup(opts) require("nvim-tree.actions.expand-all").setup(opts) diff --git a/lua/nvim-tree/actions/remove-file.lua b/lua/nvim-tree/actions/remove-file.lua index 2a2d02fd..e1ea883a 100644 --- a/lua/nvim-tree/actions/remove-file.lua +++ b/lua/nvim-tree/actions/remove-file.lua @@ -25,7 +25,9 @@ local function clear_buffer(absolute_path) a.nvim_set_current_win(winnr) end a.nvim_buf_delete(buf.bufnr, { force = true }) - close_windows(buf.windows) + if M.close_window then + close_windows(buf.windows) + end return end end @@ -88,4 +90,8 @@ function M.fn(node) end end +function M.setup(opts) + M.close_window = opts.actions.remove_file.close_window +end + return M