diff --git a/lua/lazyvim/plugins/extras/ai/copilot-chat.lua b/lua/lazyvim/plugins/extras/ai/copilot-chat.lua index df3e4252..04d2a487 100644 --- a/lua/lazyvim/plugins/extras/ai/copilot-chat.lua +++ b/lua/lazyvim/plugins/extras/ai/copilot-chat.lua @@ -11,23 +11,41 @@ function M.pick(kind) end -- Get the picker wanted (configured) by the user - local configured_picker = LazyVim.pick.want() + local picker = LazyVim.pick.want() - -- Sanity check if a valid picker for CopilotChat is configured - local valid_pickers = { "telescope", "fzf", "snacks" } + -- Map LazyVim picker names to CopilotChat integration modules + local picker_map = { + telescope = "telescope", + fzf = "fzflua", -- Map "fzf" to "fzflua" + snacks = "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, ", ") + -- Get the corresponding CopilotChat integration module + local integration = picker_map[picker] + + if not integration then + LazyVim.warn( + ("No integration available for picker '%s'. Ensure a supported picker is installed and configured."):format( + picker ) ) return end - -- Use the valid picker - require("CopilotChat.integrations." .. configured_picker).pick(items) + -- Check if the integration module is available + local ok, picker_module = pcall(require, "CopilotChat.integrations." .. integration) + if not ok then + LazyVim.warn( + ("Integration module '%s' for picker '%s' is not available. Ensure it is installed and enabled."):format( + integration, + picker + ) + ) + return + end + + -- Use the selected picker module + picker_module.pick(items) end end