local utils = require('config.utils') local icons = require('config.icons') utils.desc('a', 'AI') -- Copilot autosuggestions vim.g.copilot_no_tab_map = true vim.g.copilot_hide_during_completion = 0 vim.g.copilot_proxy_strict_ssl = 0 vim.keymap.set('i', '', 'copilot#Accept("\\")', { expr = true, replace_keycodes = false }) -- Copilot chat local chat = require('CopilotChat') local actions = require('CopilotChat.actions') local select = require('CopilotChat.select') local integration = require('CopilotChat.integrations.fzflua') chat.setup({ model = 'claude-3.5-sonnet', question_header = ' ' .. icons.ui.User .. ' ', answer_header = ' ' .. icons.ui.Bot .. ' ', error_header = '> ' .. icons.diagnostics.Warn .. ' ', selection = select.visual, mappings = { reset = { normal = '', insert = '', }, }, prompts = { Yarrr = { system_prompt = 'You are fascinated by pirates, so please respond in pirate speak.', }, Explain = { mapping = 'ae', description = 'AI Explain', }, Review = { mapping = 'ar', description = 'AI Review', }, Tests = { mapping = 'at', description = 'AI Tests', }, Fix = { mapping = 'af', description = 'AI Fix', }, Optimize = { mapping = 'ao', description = 'AI Optimize', }, Docs = { mapping = 'ad', description = 'AI Documentation', }, Commit = { mapping = 'ac', description = 'AI Generate Commit', }, }, }) utils.au('BufEnter', { pattern = 'copilot-*', callback = function() vim.opt_local.relativenumber = false vim.opt_local.number = false end, }) vim.keymap.set({ 'n' }, 'aa', chat.toggle, { desc = 'AI Toggle' }) vim.keymap.set({ 'v' }, 'aa', chat.open, { desc = 'AI Open' }) vim.keymap.set({ 'n' }, 'ax', chat.reset, { desc = 'AI Reset' }) vim.keymap.set({ 'n' }, 'as', chat.stop, { desc = 'AI Stop' }) vim.keymap.set({ 'n' }, 'am', chat.select_model, { desc = 'AI Model' }) vim.keymap.set({ 'n', 'v' }, 'ap', function() integration.pick(actions.prompt_actions(), { fzf_tmux_opts = { ['-d'] = '45%', }, }) end, { desc = 'AI Prompts' }) vim.keymap.set({ 'n', 'v' }, 'aq', function() vim.ui.input({ prompt = 'AI Question> ', }, function(input) if input and input ~= '' then chat.ask(input) end end) end, { desc = 'AI Question' })