1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-03 00:50:05 +08:00

feat(flygrep): add open_item_in_tab function

This commit is contained in:
wsdjeg 2022-10-07 20:40:08 +08:00
parent ed993e9284
commit 825110f2b8

View File

@ -285,7 +285,9 @@ local function get_file_pos(line)
return filename, linenr, colum return filename, linenr, colum
end end
local function open_item() local function open_item(...)
local argv = {...}
local edit_command = argv[1] or 'edit'
mpt._handle_fly = flygrep mpt._handle_fly = flygrep
local cursor = vim.api.nvim_win_get_cursor(flygrep_win_id) local cursor = vim.api.nvim_win_get_cursor(flygrep_win_id)
local line = vim.api.nvim_buf_get_lines(buffer_id, cursor[1] - 1, cursor[1], false)[1] local line = vim.api.nvim_buf_get_lines(buffer_id, cursor[1] - 1, cursor[1], false)[1]
@ -303,11 +305,16 @@ local function open_item()
previous_able = false previous_able = false
close_flygrep_win() close_flygrep_win()
update_history() update_history()
buffer.open_pos('edit', filename, liner, colum) buffer.open_pos(edit_command, filename, liner, colum)
vim.cmd('noautocmd normal! :') vim.cmd('noautocmd normal! :')
end end
end end
local function open_item_in_tab()
open_item('tabedit')
end
mpt._function_key = { mpt._function_key = {
[Key.t('<Tab>')] = next_item, [Key.t('<Tab>')] = next_item,
[Key.t('<C-j>')] = next_item, [Key.t('<C-j>')] = next_item,