feat(api): add node.open.drop() (#2164)
Co-authored-by: Alexander Courtis <alex@courtis.org>
This commit is contained in:
parent
9c60947926
commit
0df384b6c0
@ -1608,6 +1608,15 @@ node.open.vertical() *nvim-tree-api.node.open.vertical()*
|
||||
node.open.horizontal() *nvim-tree-api.node.open.horizontal()*
|
||||
|nvim-tree-api.node.edit()|, file will be opened in a new horizontal split.
|
||||
|
||||
node.open.drop() *nvim-tree-api.node.open.drop()*
|
||||
Switch to window with selected file if it exists.
|
||||
Open file otherwise.
|
||||
See: `:h :drop`.
|
||||
|
||||
File: open file using `:drop`
|
||||
Folder: expand or collapse
|
||||
Root: change directory up
|
||||
|
||||
node.open.tab() *nvim-tree-api.node.open.tab()*
|
||||
|nvim-tree-api.node.edit()|, file will be opened in a new tab.
|
||||
|
||||
|
||||
@ -160,6 +160,13 @@ local function open_file_in_tab(filename)
|
||||
vim.cmd("tabe " .. vim.fn.fnameescape(filename))
|
||||
end
|
||||
|
||||
local function drop(filename)
|
||||
if M.quit_on_open then
|
||||
view.close()
|
||||
end
|
||||
vim.cmd("drop " .. vim.fn.fnameescape(filename))
|
||||
end
|
||||
|
||||
local function tab_drop(filename)
|
||||
if M.quit_on_open then
|
||||
view.close()
|
||||
@ -303,6 +310,10 @@ function M.fn(mode, filename)
|
||||
return open_file_in_tab(filename)
|
||||
end
|
||||
|
||||
if mode == "drop" then
|
||||
return drop(filename)
|
||||
end
|
||||
|
||||
if mode == "tab_drop" then
|
||||
return tab_drop(filename)
|
||||
end
|
||||
|
||||
@ -162,6 +162,7 @@ local function open_preview(node)
|
||||
end
|
||||
|
||||
Api.node.open.edit = wrap_node(open_or_expand_or_dir_up "edit")
|
||||
Api.node.open.drop = wrap_node(open_or_expand_or_dir_up "drop")
|
||||
Api.node.open.tab_drop = wrap_node(open_or_expand_or_dir_up "tab_drop")
|
||||
Api.node.open.replace_tree_buffer = wrap_node(open_or_expand_or_dir_up "edit_in_place")
|
||||
Api.node.open.no_window_picker = wrap_node(open_or_expand_or_dir_up "edit_no_picker")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user