Add split options when open preview file

neovim_0.6
ray-x 3 years ago
parent 890b3c5f7f
commit 2cb2b23c6d

@ -329,6 +329,8 @@ require'navigator'.setup({
| n | \<Ctrl-w\>j | move cursor to preview (windows move to bottom view point)|
| n | \<Ctrl-w\>k | move cursor to list (windows move to up view point)|
| i/n | \<C-o\> | open preview file in nvim/Apply action|
| n | \<C-v\> | open preview file in nvim with vsplit|
| n | \<C-s\> | open preview file in nvim with split|
| n | \<Enter\> | open preview file in nvim/Apply action|
| i/n | \<C-b\> | previous page in listview|
| i/n | \<C-f\> | next page in listview|

@ -178,10 +178,12 @@ function M.new_list_view(opts)
-- data = display_data,
data = data,
border = border,
on_confirm = opts.on_confirm or function(item)
on_confirm = opts.on_confirm or function(item, split_opts)
log(split_opts)
split_opts = split_opts or {}
if item.filename ~= nil then
log("openfile ", item.filename, item.lnum, item.col)
util.open_file_at(item.filename, item.lnum, item.col)
util.open_file_at(item.filename, item.lnum, item.col, split_opts.split)
end
end,
transparency = transparency,

@ -282,8 +282,15 @@ M.open_file = function(filename)
vim.api.nvim_command(string.format("e! %s", filename))
end
M.open_file_at = function(filename, line, col)
vim.api.nvim_command(string.format("e! +%s %s", line, filename))
M.open_file_at = function(filename, line, col, split)
if split == nil then
-- code
vim.api.nvim_command(string.format("e! +%s %s", line, filename))
elseif split == 'v' then
vim.api.nvim_command(string.format("vsp! +%s %s", line, filename))
elseif split == 's' then
vim.api.nvim_command(string.format("sp! +%s %s", line, filename))
end
-- vim.api.nvim_command(string.format("e! %s", filename))
col = col or 1
vim.fn.cursor(line, col)

Loading…
Cancel
Save