feat: optional path argument for NvimTreeToggle and NvimTreeFindFileToggle (#1276)
This commit is contained in:
@@ -31,7 +31,7 @@ closes the tree
|
|||||||
|
|
||||||
|:NvimTreeToggle| *:NvimTreeToggle*
|
|:NvimTreeToggle| *:NvimTreeToggle*
|
||||||
|
|
||||||
open or close the tree
|
open or close the tree. Takes an optional path argument.
|
||||||
|
|
||||||
|:NvimTreeFocus| *:NvimTreeFocus*
|
|:NvimTreeFocus| *:NvimTreeFocus*
|
||||||
|
|
||||||
@@ -52,7 +52,8 @@ It will also open the leafs of the tree leading to the file in the buffer
|
|||||||
|:NvimTreeFindFileToggle| *:NvimTreeFindFileToggle*
|
|: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|
|
similar to combination of |:NvimTreeToggle| and |:NvimTreeFindFile|. Takes an
|
||||||
|
optional path argument.
|
||||||
|
|
||||||
|:NvimTreeClipboard| *:NvimTreeClipboard*
|
|:NvimTreeClipboard| *:NvimTreeClipboard*
|
||||||
|
|
||||||
|
|||||||
@@ -26,12 +26,12 @@ end
|
|||||||
---@deprecated
|
---@deprecated
|
||||||
M.on_keypress = require("nvim-tree.actions").on_keypress
|
M.on_keypress = require("nvim-tree.actions").on_keypress
|
||||||
|
|
||||||
function M.toggle(find_file, no_focus)
|
function M.toggle(find_file, no_focus, cwd)
|
||||||
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()
|
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)
|
||||||
end
|
end
|
||||||
@@ -259,18 +259,18 @@ local function setup_vim_commands()
|
|||||||
M.open(res.args)
|
M.open(res.args)
|
||||||
end, { nargs = "?", complete = "dir" })
|
end, { nargs = "?", complete = "dir" })
|
||||||
api.nvim_create_user_command("NvimTreeClose", view.close, {})
|
api.nvim_create_user_command("NvimTreeClose", view.close, {})
|
||||||
api.nvim_create_user_command("NvimTreeToggle", function()
|
api.nvim_create_user_command("NvimTreeToggle", function(res)
|
||||||
M.toggle(false)
|
M.toggle(false, false, res.args)
|
||||||
end, {})
|
end, { nargs = "?", complete = "dir" })
|
||||||
api.nvim_create_user_command("NvimTreeFocus", M.focus, {})
|
api.nvim_create_user_command("NvimTreeFocus", M.focus, {})
|
||||||
api.nvim_create_user_command("NvimTreeRefresh", reloaders.reload_explorer, {})
|
api.nvim_create_user_command("NvimTreeRefresh", reloaders.reload_explorer, {})
|
||||||
api.nvim_create_user_command("NvimTreeClipboard", copy_paste.print_clipboard, {})
|
api.nvim_create_user_command("NvimTreeClipboard", copy_paste.print_clipboard, {})
|
||||||
api.nvim_create_user_command("NvimTreeFindFile", function()
|
api.nvim_create_user_command("NvimTreeFindFile", function()
|
||||||
M.find_file(true)
|
M.find_file(true)
|
||||||
end, {})
|
end, {})
|
||||||
api.nvim_create_user_command("NvimTreeFindFileToggle", function()
|
api.nvim_create_user_command("NvimTreeFindFileToggle", function(res)
|
||||||
M.toggle(true)
|
M.toggle(true, false, res.args)
|
||||||
end, {})
|
end, { 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 })
|
end, { nargs = 1 })
|
||||||
|
|||||||
Reference in New Issue
Block a user