diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index 8c295e2a..56c5bc9b 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -122,12 +122,16 @@ Setup should be run in a lua file or in a |lua-heredoc| if using in a vim file. (if you opened a file with something else than the NvimTree, like `fzf` or `:split`) + Invoke with a bang `:NvimTreeFindFile!` to update the root. + |:NvimTreeFindFileToggle| close the tree or change the cursor in the tree for the current bufname, similar to combination of |:NvimTreeToggle| and |:NvimTreeFindFile|. Takes an optional path argument. + Invoke with a bang `:NvimTreeFindFileToggle!` to update the root. + |:NvimTreeClipboard| Print clipboard content for both cut and copy diff --git a/lua/nvim-tree.lua b/lua/nvim-tree.lua index d68f32e7..99ccff85 100644 --- a/lua/nvim-tree.lua +++ b/lua/nvim-tree.lua @@ -71,14 +71,14 @@ end ---@deprecated M.on_keypress = require("nvim-tree.actions.dispatch").dispatch -function M.toggle(find_file, no_focus, cwd) +function M.toggle(find_file, no_focus, cwd, bang) if view.is_visible() then view.close() else local previous_buf = api.nvim_get_current_buf() M.open(cwd) if _config.update_focused_file.enable or find_file then - M.find_file(false, previous_buf) + M.find_file(false, previous_buf, bang) end if no_focus then vim.cmd "noautocmd wincmd p" @@ -310,8 +310,8 @@ local function setup_vim_commands() M.find_file(true, nil, res.bang) end, { bang = true, bar = true }) api.nvim_create_user_command("NvimTreeFindFileToggle", function(res) - M.toggle(true, false, res.args) - end, { nargs = "?", complete = "dir" }) + M.toggle(true, false, res.args, res.bang) + end, { bang = true, nargs = "?", complete = "dir" }) api.nvim_create_user_command("NvimTreeResize", function(res) M.resize(res.args) end, { nargs = 1, bar = true })