chore: document :NvimTreeFindFile! and add bang :NvimTreeFindFileToggle!

This commit is contained in:
Alexander Courtis 2022-09-22 14:18:49 +10:00 committed by GitHub
parent fbd421da71
commit 540055be5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -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

View File

@ -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 })