mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-08-17 16:01:50 +02:00
refactor(copilot-chat): dynamically handle available pickers
Previously the picker selection was hardcoded to check for fzf-lua and snacks in a specific order. Now it uses the user's configured picker from LazyVim settings and validates it against supported pickers (currently telescope, fzf, snacks).
This commit is contained in:
parent
a0858f6085
commit
3147a56b0f
1 changed files with 19 additions and 3 deletions
|
@ -9,9 +9,25 @@ function M.pick(kind)
|
||||||
LazyVim.warn("No " .. kind .. " found on the current line")
|
LazyVim.warn("No " .. kind .. " found on the current line")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local fzf_ok = pcall(require, "fzf-lua")
|
|
||||||
local snacks_ok = pcall(require, "snacks")
|
-- Get the picker wanted (configured) by the user
|
||||||
require("CopilotChat.integrations." .. (fzf_ok and "fzflua" or snacks_ok and "snacks" or "telescope")).pick(items)
|
local configured_picker = LazyVim.pick.want()
|
||||||
|
|
||||||
|
-- Sanity check if a valid picker for CopilotChat is configured
|
||||||
|
local valid_pickers = { "telescope", "fzf", "snacks" }
|
||||||
|
|
||||||
|
if not vim.tbl_contains(valid_pickers, configured_picker) then
|
||||||
|
LazyVim.error(
|
||||||
|
("Invalid picker: '%s'. Ensure one of the following is installed and configured: %s"):format(
|
||||||
|
configured_picker,
|
||||||
|
table.concat(valid_pickers, ", ")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Use the valid picker
|
||||||
|
require("CopilotChat.integrations." .. configured_picker).pick(items)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue