From b903bc371ff8dbaf581e574cce3733755c10debe Mon Sep 17 00:00:00 2001 From: Lucas Garcia Rubio Date: Fri, 9 May 2025 09:14:47 -0300 Subject: [PATCH] configure some AI agents --- init.lua | 3 +- lazy-lock.json | 4 ++- lua/custom/plugins/codecompanion.lua | 45 +++++++++++++++++++++++----- lua/custom/plugins/copilot.lua | 11 ------- lua/custom/plugins/copilotchat.lua | 23 ++++++++++++++ lua/custom/plugins/mcphub.lua | 25 ++++++++++++++++ 6 files changed, 90 insertions(+), 21 deletions(-) delete mode 100644 lua/custom/plugins/copilot.lua create mode 100644 lua/custom/plugins/copilotchat.lua create mode 100644 lua/custom/plugins/mcphub.lua diff --git a/init.lua b/init.lua index d4929add..2a1dd3a5 100644 --- a/init.lua +++ b/init.lua @@ -654,7 +654,7 @@ require('lazy').setup({ -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local servers = { -- clangd = {}, - -- gopls = {}, + gopls = {}, -- pyright = {}, -- rust_analyzer = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs @@ -994,6 +994,7 @@ require('lazy').setup({ 'yaml', 'css', 'sql', + 'go', }, -- Autoinstall languages that are not installed auto_install = true, diff --git a/lazy-lock.json b/lazy-lock.json index d0812950..a6be4cd1 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -4,7 +4,7 @@ "cmp-nvim-lsp": { "branch": "main", "commit": "a8912b88ce488f411177fc8aed358b04dc246d7b" }, "cmp-path": { "branch": "main", "commit": "c6635aae33a50d6010bf1aa756ac2398a2d54c32" }, "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, - "codecompanion.nvim": { "branch": "main", "commit": "3f2cb946f1659133c6754d43990d6c70fd81baf6" }, + "codecompanion.nvim": { "branch": "main", "commit": "29ded250b186c550222aa6a4a648e52ad49dd85f" }, "conform.nvim": { "branch": "master", "commit": "eebc724d12c5579d733d1f801386e0ceb909d001" }, "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, "fidget.nvim": { "branch": "main", "commit": "d9ba6b7bfe29b3119a610892af67602641da778e" }, @@ -17,6 +17,7 @@ "mason-nvim-dap.nvim": { "branch": "main", "commit": "4c2cdc69d69fe00c15ae8648f7e954d99e5de3ea" }, "mason-tool-installer.nvim": { "branch": "main", "commit": "1255518cb067e038a4755f5cb3e980f79b6ab89c" }, "mason.nvim": { "branch": "main", "commit": "fc98833b6da5de5a9c5b1446ac541577059555be" }, + "mcphub.nvim": { "branch": "main", "commit": "f3c4613ecc9a57326e7ab78383db909ec4865ec6" }, "mini.nvim": { "branch": "main", "commit": "e744b5dbb3158242af77124bd6763a8647ea82ed" }, "neo-tree.nvim": { "branch": "main", "commit": "9b5d67119c46e3262ffe1508fe6d8540b79ad75d" }, "neogit": { "branch": "master", "commit": "0542ca3aa9bf0b67b7b7713e4d230f9c1fc2c631" }, @@ -44,6 +45,7 @@ "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, "tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" }, + "vim-be-good": { "branch": "master", "commit": "0ae3de14eb8efc6effe7704b5e46495e91931cc5" }, "vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }, "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" } } diff --git a/lua/custom/plugins/codecompanion.lua b/lua/custom/plugins/codecompanion.lua index d6282c58..35988404 100644 --- a/lua/custom/plugins/codecompanion.lua +++ b/lua/custom/plugins/codecompanion.lua @@ -7,12 +7,41 @@ return { 'nvim-treesitter/nvim-treesitter', }, opts = { + display = { + chat = { + show_settings = true, + }, + }, + extensions = { + mcphub = { + callback = 'mcphub.extensions.codecompanion', + opts = { + make_vars = true, + make_slash_commands = true, + show_result_in_chat = true, + }, + }, + }, + adapters = { + copilot = function() + return require('codecompanion.adapters').extend('copilot', { + schema = { + model = { + default = 'gpt-4o', + }, + }, + }) + end, + }, strategies = { chat = { - adapter = 'openai', + adapter = 'copilot', }, inline = { - adapter = 'openai', + adapter = 'copilot', + }, + cmd = { + adapter = 'copilot', }, }, prompt_library = { @@ -34,13 +63,13 @@ return { vim.g.codecompanion_auto_tool_mode = true return [[### Steps to Follow -You are required to create a Pull Request description based on the file at .github/pull_request_template.md. You must use @cmd_runner to read that file. + You are required to create a Pull Request description based on the file at .github/pull_request_template.md. You must use @cmd_runner to read that file. -1. The file is in Portuguese, so you must complete the description in Portuguese as well. -2. Use @cmd_runner to get the git diff of the current branch, by using the command `git diff origin/HEAD`. -3. Based on that diff, you will generate a Pull Request description based on .github/pull_request_template.md. -4. If necessary, you can obtain the name of the branch by using the command `git rev-parse --abbrev-ref HEAD`. -5. Write the entire pull request description.]] + 1. The file is in Portuguese, so you must complete the description in Portuguese as well. + 2. Use @cmd_runner to get the git diff of the current branch, by using the command `git diff origin/HEAD`. + 3. Based on that diff, you will generate a Pull Request description based on .github/pull_request_template.md. + 4. If necessary, you can obtain the name of the branch by using the command `git rev-parse --abbrev-ref HEAD`. + 5. Write the entire pull request description.]] end, }, }, diff --git a/lua/custom/plugins/copilot.lua b/lua/custom/plugins/copilot.lua deleted file mode 100644 index 9ee26470..00000000 --- a/lua/custom/plugins/copilot.lua +++ /dev/null @@ -1,11 +0,0 @@ -return { - -- { - -- 'CopilotC-Nvim/CopilotChat.nvim', - -- dependencies = { - -- { 'zbirenbaum/copilot.lua' }, -- 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 = {}, - -- }, -} diff --git a/lua/custom/plugins/copilotchat.lua b/lua/custom/plugins/copilotchat.lua new file mode 100644 index 00000000..01f131ba --- /dev/null +++ b/lua/custom/plugins/copilotchat.lua @@ -0,0 +1,23 @@ +return { + -- { + -- 'CopilotC-Nvim/CopilotChat.nvim', + -- dependencies = { + -- -- { 'zbirenbaum/copilot.lua' }, -- or zbirenbaum/copilot.lua + -- { 'github/copilot.vim' }, + -- { 'nvim-lua/plenary.nvim', branch = 'master' }, -- for curl, log and async functions + -- }, + -- build = 'make tiktoken', -- Only on MacOS or Linux + -- opts = {}, + -- -- config = function() + -- -- require('copilot').setup { + -- -- suggestion = { + -- -- enabled = false, + -- -- auto_trigger = true, + -- -- keymap = { + -- -- accept = '', + -- -- }, + -- -- }, + -- -- } + -- -- end, + -- }, +} diff --git a/lua/custom/plugins/mcphub.lua b/lua/custom/plugins/mcphub.lua new file mode 100644 index 00000000..57d928b6 --- /dev/null +++ b/lua/custom/plugins/mcphub.lua @@ -0,0 +1,25 @@ +return { + 'ravitemer/mcphub.nvim', + dependencies = { + 'nvim-lua/plenary.nvim', -- Required for Job and HTTP requests + }, + -- uncomment the following line to load hub lazily + --cmd = "MCPHub", -- lazy load + build = 'npm install -g mcp-hub@latest', -- Installs required mcp-hub npm module + -- uncomment this if you don't want mcp-hub to be available globally or can't use -g + -- build = "bundled_build.lua", -- Use this and set use_bundled_binary = true in opts (see Advanced configuration) + config = function() + require('mcphub').setup { + extensions = { + codecompanion = { + -- Show the mcp tool result in the chat buffer + show_result_in_chat = true, + -- Make chat #variables from MCP server resources + make_vars = true, + -- Create slash commands for prompts + make_slash_commands = true, + }, + }, + } + end, +}