local utils = require('CopilotChat.utils') local M = {} local default_prompts = { Explain = 'Explain how it works.', Tests = 'Briefly how selected code works then generate unit tests.', } _COPILOT_CHAT_GLOBAL_CONFIG = {} -- Set up the plugin ---@param options (table | nil) -- - show_help: ('yes' | 'no') default: 'yes'. -- - prompts: (table?) default: default_prompts. -- - debug: (boolean?) default: false. M.setup = function(options) vim.g.copilot_chat_show_help = options and options.show_help or 'yes' local debug = options and options.debug or false _COPILOT_CHAT_GLOBAL_CONFIG.debug = debug -- Merge the provided prompts with the default prompts local prompts = vim.tbl_extend('force', default_prompts, options and options.prompts or {}) vim.g.copilot_chat_user_prompts = prompts -- Loop through merged table and generate commands based on keys. for key, value in pairs(prompts) do utils.create_cmd('CopilotChat' .. key, function() vim.cmd('CopilotChat ' .. value) end, { nargs = '*', range = true }) end utils.log_info( 'Execute ":UpdateRemotePlugins" and restart Neovim before starting a chat with Copilot.' ) utils.log_info('If issues arise, run ":healthcheck" and share the output.') end return M