neovim: open multiple files in telescope
https://github.com/nvim-telescope/telescope.nvim/issues/1048
This commit is contained in:
parent
a4bebfef29
commit
195c81f8b1
|
@ -62,6 +62,26 @@ nmap <leader>n :NnnPicker %<CR>
|
|||
nmap <leader>N :NnnPicker<CR>
|
||||
|
||||
lua <<EOF
|
||||
local multiopen = function(prompt_bufnr)
|
||||
local picker = require('telescope.actions.state').get_current_picker(prompt_bufnr)
|
||||
local multi = picker:get_multi_selection()
|
||||
|
||||
if vim.tbl_isempty(multi) then
|
||||
require('telescope.actions').select_default(prompt_bufnr)
|
||||
return
|
||||
end
|
||||
|
||||
require('telescope.actions').close(prompt_bufnr)
|
||||
for _, entry in pairs(multi) do
|
||||
local filename = entry.filename or entry.value
|
||||
local lnum = entry.lnum or 1
|
||||
local lcol = entry.col or 1
|
||||
if filename then
|
||||
vim.cmd(string.format("tabnew +%d %s", lnum, filename))
|
||||
vim.cmd(string.format("normal! %dG%d|", lnum, lcol))
|
||||
end
|
||||
end
|
||||
end
|
||||
local actions = require("telescope.actions")
|
||||
local telescope = require("telescope")
|
||||
telescope.setup{
|
||||
|
@ -74,6 +94,9 @@ telescope.setup{
|
|||
["K"] = actions.move_to_bottom,
|
||||
["<C-c>"] = actions.close,
|
||||
},
|
||||
i = {
|
||||
['<CR>'] = multiopen,
|
||||
}
|
||||
},
|
||||
},
|
||||
pickers = {
|
||||
|
|
Loading…
Reference in a new issue