From 9b7605db11c894305e029af300e4da52e8e4c6cc Mon Sep 17 00:00:00 2001 From: OdysseusOperator Date: Fri, 28 Mar 2025 13:17:49 +0100 Subject: [PATCH] feat(plugins): add Copilot and CopilotChat configurations This commit introduces configurations for GitHub Copilot and Copilot Chat plugins in the Neovim setup. It includes the setup of keybindings for toggling Copilot and various chat functionalities, enhancing the development experience through AI-assisted programming features. --- lua/custom/plugins/init.lua | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index 83de0aac..3d5536f2 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -144,4 +144,41 @@ return { vim.cmd.colorscheme 'gruvbox-material' end, }, + { + 'github/copilot.vim', + config = function() + vim.cmd [[Copilot disable]] + + -- Keybinding to toggle Copilot + vim.keymap.set('n', 'cp', function() + vim.cmd [[Copilot toggle]] + end, { noremap = true, silent = true, desc = 'Toggle Copilot' }) + end, + }, + { + 'CopilotC-Nvim/CopilotChat.nvim', + dependencies = { + { 'github/copilot.vim' }, -- or zbirenbaum/copilot.lua + { 'nvim-lua/plenary.nvim', branch = 'master' }, -- for curl, log and async functions + }, + build = 'make tiktoken', -- Only on MacOS or Linux + opts = { + -- See Configuration section for options + }, + config = function() + local chat = require 'CopilotChat' + chat.setup() + 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', 'ar', ':CopilotChatFix', { desc = 'AI Fix' }) + + vim.keymap.set('n', 'at', ':CopilotChatTests', { desc = 'AI Tests' }) + vim.keymap.set('n', 'ad', ':CopilotChatDocs', { desc = 'AI Docs' }) + vim.keymap.set('n', 'ar', ':CopilotChatReview', { desc = 'AI Review' }) + end, + -- See Commands section for default commands if you want to lazy load on them + }, } -- end of return