Opening multiple files at once in telescope pickers and codecompanion #1024
jmmarotta
started this conversation in
Show and tell
Replies: 1 comment
-
Hi, thanks for sharing your solution. I was struggling with this and you helped a lot! I made a version based on yours, using local select_one_or_multi = function(prompt_bufnr)
local files = {}
require("telescope.actions.utils").map_selections(prompt_bufnr, function(entry, _)
table.insert(files, entry.path)
end)
if #files == 0 then
local selection = require("telescope.actions.state").get_selected_entry()
if selection and selection.path then
table.insert(files, selection.path)
end
end
local picker_type = require("telescope.actions.state").get_current_picker(prompt_bufnr).prompt_title or ""
local is_not_find_and_edit = string.find(picker_type, "Select file%(s%)")
or string.find(picker_type, "Select buffer%(s%)")
if is_not_find_and_edit then
require("telescope.actions").select_default(prompt_bufnr)
return
end
actions.close(prompt_bufnr)
for _, file in ipairs(files) do
if file ~= nil then
vim.cmd(string.format("edit %s", file))
end
end
end |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I modified a function to enable opening multiple files in Telescope, making it compatible with CodeCompanion. It's hacky, but it works.
In your telescope config:
Beta Was this translation helpful? Give feedback.
All reactions