From 44eca8b20d9ded5c09dfb998fbf2bbaae24be01b Mon Sep 17 00:00:00 2001 From: Joao P Dubas Date: Wed, 7 May 2025 11:39:51 +0000 Subject: [PATCH] feat(nvim): move from avante to codecompanion (#222) Change the AI tool from [avante][0] to [codecompanion][1] to check if it's a better alternative. Also, install additional tools such as: * [mcphub][2] * [vectorcode][3] These should improve the experience with AI tooling. Reviewed-on: https://gitea.dubas.dev/joao.dubas/ide/pulls/222 [0]: https://github.com/yetone/avante.nvim [1]: https://codecompanion.olimorris.dev/ [2]: https://github.com/ravitemer/mcphub.nvim [3]: https://github.com/Davidyz/VectorCode Co-authored-by: Joao P Dubas Co-committed-by: Joao P Dubas --- config/mcphub/config.json | 21 ++ config/mise/config.toml | 2 +- config/nvim/lua/custom/plugins/init.lua | 257 +++++++++++++----------- config/vectorcode/config.json5 | 4 + docker-compose.yml | 4 +- 5 files changed, 168 insertions(+), 120 deletions(-) create mode 100644 config/mcphub/config.json create mode 100644 config/vectorcode/config.json5 diff --git a/config/mcphub/config.json b/config/mcphub/config.json new file mode 100644 index 0000000..8199571 --- /dev/null +++ b/config/mcphub/config.json @@ -0,0 +1,21 @@ +{ + "mcpServers": { + "context7": { + "command": "pnpm", + "args": [ + "dlx", + "@upstash/context7-mcp@latest" + ] + }, + "git": { + "command": "uvx", + "args": [ + "mcp-server-git" + ] + }, + "vectorcode": { + "command": "vectorcode-mcp-server", + "args": [] + } + } +} diff --git a/config/mise/config.toml b/config/mise/config.toml index b5a6ba5..368affd 100644 --- a/config/mise/config.toml +++ b/config/mise/config.toml @@ -29,7 +29,7 @@ "go:github.com/bloznelis/typioca" = "3.1.0" "npm:@anthropic-ai/claude-code" = "0.2.78" "pipx:aider-chat" = { version = "0.82.2", uvx_args = "--python 3.12.7 --with google-generativeai" } -"pipx:vectorcode" = { version = "0.5.6", uvx_args = "--python 3.13.2" } +"pipx:vectorcode" = { version = "0.5.6", uvx_args = "--python 3.13.2", extras = "mcp" } "ubi:Samyak2/toipe" = "0.5.0" "ubi:hlsxx/tukai" = "0.2.2" "ubi:jdx/usage" = "2.0.7" diff --git a/config/nvim/lua/custom/plugins/init.lua b/config/nvim/lua/custom/plugins/init.lua index 6bba1f2..f489937 100644 --- a/config/nvim/lua/custom/plugins/init.lua +++ b/config/nvim/lua/custom/plugins/init.lua @@ -145,137 +145,158 @@ return { end, }, { - 'yetone/avante.nvim', - event = 'VeryLazy', - lazy = false, - version = false, + 'ravitemer/mcphub.nvim', + dependencies = { + 'nvim-lua/plenary.nvim', + }, + cmd = 'MCPHub', + build = 'bundled_build.lua', opts = { - provider = 'gemini_pro', - auto_suggestion_provider = 'gemini_flash', - claude = { - model = 'claude-3-7-sonnet-20250219', - temperature = 0, - max_tokens = 20480, - }, - vendors = { - gemini_pro = { - __inherited_from = 'gemini', - model = 'gemini-2.5-pro-exp-03-25', - temperature = 0.25, - max_tokens = 204800, - }, - gemini_flash = { - __inherited_from = 'gemini', - model = 'gemini-2.0-flash', - temperature = 0.25, - max_tokens = 20480, - }, - }, - behaviour = { - auto_suggestions = false, - auto_set_highlight_group = true, - aute_set_keymaps = true, - auto_apply_diff_after_generation = true, - support_paste_from_clipboard = false, - minimize_diff = true, - }, - mappings = { - diff = { - ours = 'co', - theirs = 'ct', - all_theirs = 'ca', - both = 'cb', - cursor = 'cc', - next = ']x', - prev = '[x', - }, - suggestion = { - accept = '', - next = '', - prev = '', - dismiss = '', - }, - jump = { - next = ']]', - prev = '[[', - }, - submit = { - normal = '', - insert = '', - }, - sidebar = { - apply_all = 'A', - apply_cursor = 'a', - switch_windows = '', - reverse_switch_windows = '', - }, - }, - hints = { enabled = true }, - windows = { - position = 'right', - wrap = true, - width = 30, - sidebar_header = { - enabled = true, - align = 'center', - rounded = true, - }, - input = { - prefix = '> ', - height = 8, - }, - edit = { + port = 37373, + config = vim.fn.expand '~/.config/mcphub/servers.json', + native_servers = {}, + auto_approve = true, + auto_toggle_mcp_servers = true, + extensions = {}, + ui = { + window = { + width = 0.8, + height = 0.8, + relative = 'editor', + zindex = 50, border = 'rounded', - start_insert = true, - }, - ask = { - floating = false, - start_insert = true, - border = 'rounded', - focus_on_apply = 'ours', }, + wo = {}, }, - highlights = { - diff = { - current = 'DiffText', - incoming = 'DiffAdd', - }, - }, - diff = { - autojump = true, - list_opener = 'copen', - override_timeoutlen = 500, + use_bundled_binary = true, + log = { + level = vim.log.levels.WARN, + prefix = '[MCPHub]', }, }, - build = 'make', + }, + { + 'Davidyz/VectorCode', dependencies = { - 'nvim-treesitter/nvim-treesitter', - 'stevearc/dressing.nvim', 'nvim-lua/plenary.nvim', - 'MunifTanjim/nui.nvim', - 'hrsh7th/nvim-cmp', - 'nvim-telescope/telescope.nvim', - 'nvim-tree/nvim-web-devicons', - { - 'HakonHarnes/img-clip.nvim', - event = 'VeryLazy', - opts = { - default = { - embed_image_as_base64 = false, - prompt_for_file_name = false, - drag_and_drop = { - insert_mode = true, - }, - use_absolute_path = true, - }, + }, + version = vim.fn.system { 'mise', 'current', 'pipx:vectorcode' }, + opts = function() + return { + async_opts = { + debounce = 10, + events = { 'BufWritePost', 'InsertEnter', 'BufReadPost' }, + exclude_this = true, + n_query = 1, + notify = false, + query_cb = require('vectorcode.utils').make_surrounding_lines_cb(-1), + run_on_register = false, }, - }, + async_backend = 'default', + exclude_this = true, + n_query = 1, + notify = true, + timeout_ms = 5000, + on_setup = { + update = false, + lsp = false, + }, + sync_log_env_var = false, + } + end, + }, + { + 'olimorris/codecompanion.nvim', + dependencies = { + 'nvim-lua/plenary.nvim', + 'nvim-treesitter/nvim-treesitter', { 'MeanderingProgrammer/render-markdown.nvim', opts = { - file_types = { 'markdown', 'Avante' }, + file_types = { 'markdown', 'codecompanion' }, }, - ft = { 'markdown', 'Avante' }, + ft = { 'markdown', 'codecompanion' }, + }, + }, + opts = function() + return { + display = { + action_palette = { + width = 95, + height = 15, + prompt = 'Prompt', + provide = 'telescope', + }, + }, + adapters = { + gemini_pro = function() + return require('codecompanion.adapters').extend('gemini', { + name = 'gemini_pro', + schema = { + model = { + default = 'gemini-2.5-pro-exp-03-25', + }, + }, + }) + end, + gemini_flash = function() + return require('codecompanion.adapters').extend('gemini', { + name = 'gemini_flash', + schema = { + model = { + default = 'gemini-2.0-flash', + }, + }, + }) + end, + }, + extensions = { + vectorcode = { + opts = { + add_tool = true, + add_slash_command = true, + tool_opts = {}, + }, + }, + mcphub = { + callback = 'mcphub.extensions.codecompanion', + opts = { + make_slash_commands = true, + make_vars = true, + show_result_in_chat = true, + }, + }, + }, + strategies = { + chat = { adapter = 'gemini_pro' }, + inline = { adapter = 'gemini_flash' }, + }, + } + end, + keys = { + { + 'aa', + 'CodeCompanionActions', + mode = { 'n', 'v' }, + desc = 'CodeCompaion actions', + noremap = true, + silent = true, + }, + { + 'at', + 'CodeCompanionChat Toggle', + mode = { 'n', 'v' }, + desc = 'CodeCompanion toggle chat', + noremap = true, + silent = true, + }, + { + 'ga', + 'CodeCompanionChat add', + mode = 'v', + desc = 'CodeCompanion add to chat', + noremap = true, + silent = true, }, }, }, diff --git a/config/vectorcode/config.json5 b/config/vectorcode/config.json5 new file mode 100644 index 0000000..638ab7c --- /dev/null +++ b/config/vectorcode/config.json5 @@ -0,0 +1,4 @@ +{ + "host": "chroma", + "port": "8000" +} diff --git a/docker-compose.yml b/docker-compose.yml index 99aef8c..5637cdf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,11 +21,13 @@ services: volumes: - './config/atuin:/home/coder/.config/atuin' - './config/git:/home/coder/.config/git' + - './config/mcphub:/home/coder/.config/mcphub' - './config/mise:/home/coder/.config/mise' - './config/nvim/lua/custom:/home/coder/.config/nvim/lua/custom' - './config/starship:/home/coder/.config/starship' - './config/tmux:/home/coder/.config/tmux' - './config/tmuxp:/home/coder/.config/tmuxp' + - './config/vectorcode:/home/coder/.config/vectorcode' - 'home_cache:/home/coder/.cache' - 'home_local_share:/home/coder/.local/share' - 'home_local_state:/home/coder/.local/state' @@ -42,7 +44,7 @@ services: volumes: - 'chroma_data:/data' ports: - - '${IDE_CHROMA_PORT:-8000}' + - '${IDE_CHROMA_PORT:-18000:8000}' volumes: home_cache: {}