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 (if you opened a file with something else than the NvimTree, like `fzf` or
`:split`) `:split`)
Invoke with a bang `:NvimTreeFindFile!` to update the root.
|:NvimTreeFindFileToggle| |:NvimTreeFindFileToggle|
close the tree or change the cursor in the tree for the current bufname, close the tree or change the cursor in the tree for the current bufname,
similar to combination of |:NvimTreeToggle| and |:NvimTreeFindFile|. Takes an similar to combination of |:NvimTreeToggle| and |:NvimTreeFindFile|. Takes an
optional path argument. optional path argument.
Invoke with a bang `:NvimTreeFindFileToggle!` to update the root.
|:NvimTreeClipboard| |:NvimTreeClipboard|
Print clipboard content for both cut and copy Print clipboard content for both cut and copy

View File

@ -71,14 +71,14 @@ end
---@deprecated ---@deprecated
M.on_keypress = require("nvim-tree.actions.dispatch").dispatch 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 if view.is_visible() then
view.close() view.close()
else else
local previous_buf = api.nvim_get_current_buf() local previous_buf = api.nvim_get_current_buf()
M.open(cwd) M.open(cwd)
if _config.update_focused_file.enable or find_file then if _config.update_focused_file.enable or find_file then
M.find_file(false, previous_buf) M.find_file(false, previous_buf, bang)
end end
if no_focus then if no_focus then
vim.cmd "noautocmd wincmd p" vim.cmd "noautocmd wincmd p"
@ -310,8 +310,8 @@ local function setup_vim_commands()
M.find_file(true, nil, res.bang) M.find_file(true, nil, res.bang)
end, { bang = true, bar = true }) end, { bang = true, bar = true })
api.nvim_create_user_command("NvimTreeFindFileToggle", function(res) api.nvim_create_user_command("NvimTreeFindFileToggle", function(res)
M.toggle(true, false, res.args) M.toggle(true, false, res.args, res.bang)
end, { nargs = "?", complete = "dir" }) end, { bang = true, nargs = "?", complete = "dir" })
api.nvim_create_user_command("NvimTreeResize", function(res) api.nvim_create_user_command("NvimTreeResize", function(res)
M.resize(res.args) M.resize(res.args)
end, { nargs = 1, bar = true }) end, { nargs = 1, bar = true })