Skip to content

Commit 540055b

Browse files
authored
chore: document :NvimTreeFindFile! and add bang :NvimTreeFindFileToggle!
1 parent fbd421d commit 540055b

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

doc/nvim-tree-lua.txt

+4
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,16 @@ Setup should be run in a lua file or in a |lua-heredoc| if using in a vim file.
122122
(if you opened a file with something else than the NvimTree, like `fzf` or
123123
`:split`)
124124

125+
Invoke with a bang `:NvimTreeFindFile!` to update the root.
126+
125127
|:NvimTreeFindFileToggle|
126128

127129
close the tree or change the cursor in the tree for the current bufname,
128130
similar to combination of |:NvimTreeToggle| and |:NvimTreeFindFile|. Takes an
129131
optional path argument.
130132

133+
Invoke with a bang `:NvimTreeFindFileToggle!` to update the root.
134+
131135
|:NvimTreeClipboard|
132136

133137
Print clipboard content for both cut and copy

lua/nvim-tree.lua

+4-4
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ end
7171
---@deprecated
7272
M.on_keypress = require("nvim-tree.actions.dispatch").dispatch
7373

74-
function M.toggle(find_file, no_focus, cwd)
74+
function M.toggle(find_file, no_focus, cwd, bang)
7575
if view.is_visible() then
7676
view.close()
7777
else
7878
local previous_buf = api.nvim_get_current_buf()
7979
M.open(cwd)
8080
if _config.update_focused_file.enable or find_file then
81-
M.find_file(false, previous_buf)
81+
M.find_file(false, previous_buf, bang)
8282
end
8383
if no_focus then
8484
vim.cmd "noautocmd wincmd p"
@@ -310,8 +310,8 @@ local function setup_vim_commands()
310310
M.find_file(true, nil, res.bang)
311311
end, { bang = true, bar = true })
312312
api.nvim_create_user_command("NvimTreeFindFileToggle", function(res)
313-
M.toggle(true, false, res.args)
314-
end, { nargs = "?", complete = "dir" })
313+
M.toggle(true, false, res.args, res.bang)
314+
end, { bang = true, nargs = "?", complete = "dir" })
315315
api.nvim_create_user_command("NvimTreeResize", function(res)
316316
M.resize(res.args)
317317
end, { nargs = 1, bar = true })

0 commit comments

Comments
 (0)