feat(api): Add new node selection action based on tab :drop command (#2161)

Co-authored-by: gegoune <dev@clog.rocks>
This commit is contained in:
hinell
2023-04-23 02:41:21 +03:00
committed by GitHub
parent 967865cdb7
commit d68b00a63e
3 changed files with 21 additions and 0 deletions

View File

@@ -148,6 +148,13 @@ local function open_file_in_tab(filename)
vim.cmd("tabe " .. vim.fn.fnameescape(filename))
end
local function tab_drop(filename)
if M.quit_on_open then
view.close()
end
vim.cmd("tab :drop " .. vim.fn.fnameescape(filename))
end
local function on_preview(buf_loaded)
if not buf_loaded then
vim.bo.bufhidden = "delete"
@@ -284,6 +291,10 @@ function M.fn(mode, filename)
return open_file_in_tab(filename)
end
if mode == "tab_drop" then
return tab_drop(filename)
end
if mode == "edit_in_place" then
return edit_in_current_buf(filename)
end

View File

@@ -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.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")
Api.node.open.vertical = wrap_node(open_or_expand_or_dir_up "vsplit")