From b4404d2c1f5f0032fe60986b12feeea505f0a1c1 Mon Sep 17 00:00:00 2001 From: iofq Date: Thu, 6 Feb 2025 02:48:48 -0600 Subject: [PATCH] feat: codecompanion.nvim --- flake.lock | 12 +++--- nix/neovim-overlay.nix | 2 +- nvim/lua/plugins/ai.lua | 69 ++++++++++++++++++++++----------- nvim/lua/plugins/completion.lua | 22 ++++------- nvim/lua/plugins/lsp.lua | 3 +- nvim/lua/plugins/misc.lua | 7 +++- 6 files changed, 69 insertions(+), 46 deletions(-) diff --git a/flake.lock b/flake.lock index d50536f..8ab2bdf 100644 --- a/flake.lock +++ b/flake.lock @@ -139,11 +139,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1738410390, - "narHash": "sha256-xvTo0Aw0+veek7hvEVLzErmJyQkEcRk6PSR4zsRQFEc=", + "lastModified": 1738680400, + "narHash": "sha256-ooLh+XW8jfa+91F1nhf9OF7qhuA/y1ChLx6lXDNeY5U=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "3a228057f5b619feb3186e986dbe76278d707b6e", + "rev": "799ba5bffed04ced7067a91798353d360788b30d", "type": "github" }, "original": { @@ -167,11 +167,11 @@ }, "nixpkgs-master": { "locked": { - "lastModified": 1738557153, - "narHash": "sha256-KbuxOVz6SCBCkjJufqmdhItzhf8OCBKnRP+JWE9EFlo=", + "lastModified": 1738831044, + "narHash": "sha256-6y2I2h4hX8d+LXLCzgu7QJ3Wvkx89R0x3WFQ5ovhwco=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "3d89be6655a3ca15643456199b491b524929f61c", + "rev": "e4b6440d7ca1649bb95bd59f39b2279db959e498", "type": "github" }, "original": { diff --git a/nix/neovim-overlay.nix b/nix/neovim-overlay.nix index 5b80814..8bc35af 100644 --- a/nix/neovim-overlay.nix +++ b/nix/neovim-overlay.nix @@ -14,11 +14,11 @@ with final.pkgs.lib; let all-plugins = with pkgs.vimPlugins; [ aerial-nvim - avante-nvim inputs.nixpkgs-master.legacyPackages.${pkgs.system}.vimPlugins.blink-cmp blink-cmp-copilot blink-compat blink-ripgrep-nvim + codecompanion-nvim copilot-lua diffview-nvim eyeliner-nvim diff --git a/nvim/lua/plugins/ai.lua b/nvim/lua/plugins/ai.lua index 0be26a1..d0fe298 100644 --- a/nvim/lua/plugins/ai.lua +++ b/nvim/lua/plugins/ai.lua @@ -2,10 +2,19 @@ return { { "zbirenbaum/copilot.lua", cmd = "Copilot", + keys = { + { + 'M-\\', + 'Copilot panel', + noremap = true, + desc = 'Copilot panel' + } + }, opts = { - panel = { enabled = false }, + panel = { enabled = true, keymap = { accept = "ga" } }, suggestion = { enabled = true, + auto_trigger = true, keymap = { accept = "", next = "", @@ -43,36 +52,50 @@ return { } }, { - "yetone/avante.nvim", + "olimorris/codecompanion.nvim", cmd = "Copilot", dependencies = { - "stevearc/dressing.nvim", "nvim-lua/plenary.nvim", - "MunifTanjim/nui.nvim", + "nvim-treesitter/nvim-treesitter", "zbirenbaum/copilot.lua", - { - 'MeanderingProgrammer/render-markdown.nvim', - opts = { - file_types = { "markdown", "Avante" }, - }, - ft = { "markdown", "Avante" }, - }, }, opts = { - provider = "copilot", - -- auto_suggestions_provider = "copilot", - behavior = { - auto_suggestions = false, -- TODO + adapters = { + copilot = function() + return require("codecompanion.adapters").extend("copilot", { + name = "copilot-claude-3.5-sonnet", + schema = { model = "claude-3.5-sonnet", }, + }) + end }, - file_selector = { - provider = "native", -- TODO snacks once it's ready + strategies = { + chat = { adapter = "copilot-claude-3.5-sonnet", }, + inline = { adapter = "copilot-claude-3.5-sonnet", }, }, - windows = { - width = 50, - ask = { - floating = true - } + }, + init = function() + vim.api.nvim_create_user_command('CC', ':CodeCompanion', {}) + end, + keys = { + { + 'ac', + 'CodeCompanionChat Toggle', + noremap = true, + desc = 'Copilot chat toggle' + }, + { + 'as', + 'CodeCompanionChat Add', + noremap = true, + desc = 'Copilot chat add selection' + }, + { + 'aa', + 'CodeCompanionActions', + noremap = true, + desc = 'Copilot inline' } } - } + + }, } diff --git a/nvim/lua/plugins/completion.lua b/nvim/lua/plugins/completion.lua index cb70901..7e48e87 100644 --- a/nvim/lua/plugins/completion.lua +++ b/nvim/lua/plugins/completion.lua @@ -3,7 +3,6 @@ return { 'saghen/blink.cmp', event = "VeryLazy", dependencies = { - { "yetone/avante.nvim", lazy = true }, 'saghen/blink.compat', 'rafamadriz/friendly-snippets', 'giuxtaposition/blink-cmp-copilot', @@ -34,8 +33,7 @@ return { "snippets", "buffer", "ripgrep", - "avante_commands", - "avante_mentions", + "copilot" }, providers = { ripgrep = { @@ -43,18 +41,12 @@ return { name = "rg", score_offset = -10, }, - avante_commands = { - name = "avante_commands", - module = "blink.compat.source", - score_offset = 90, - opts = {}, + copilot = { + name = "copilot", + module = "blink-cmp-copilot", + score_offset = 100, + async = true, }, - avante_mentions = { - name = "avante_mentions", - module = "blink.compat.source", - score_offset = 1000, - opts = {}, - } } }, keymap = { @@ -77,6 +69,8 @@ return { } }, menu = { + -- auto show in cmdline + auto_show = true, draw = { treesitter = { "lsp" }, columns = { diff --git a/nvim/lua/plugins/lsp.lua b/nvim/lua/plugins/lsp.lua index e1b2443..dc4c0b0 100644 --- a/nvim/lua/plugins/lsp.lua +++ b/nvim/lua/plugins/lsp.lua @@ -7,7 +7,8 @@ return { { 'de', 'Trouble diagnostics toggle focus=true', - { noremap = true, desc = 'Trouble diagnostics' } + noremap = true, + desc = 'Trouble diagnostics' } } }, diff --git a/nvim/lua/plugins/misc.lua b/nvim/lua/plugins/misc.lua index 901c63e..67968f3 100644 --- a/nvim/lua/plugins/misc.lua +++ b/nvim/lua/plugins/misc.lua @@ -164,10 +164,15 @@ return { ring = { storage = "memory", }, + picker = { + select = { + action = require('yanky.picker').actions.set_register("+") + } + } }, keys = { { "y", "(YankyYank)", mode = { "n", "x" } }, - { "fp", "YankyRingHistory", { mode = { "n", "x" }, noremap = true, silent = true, desc = 'Pick history (yanky.nvim)' } } + { "fp", "YankyRingHistory", mode = { "n", "x" }, noremap = true, silent = true, desc = 'Pick history (yanky.nvim)' } }, }, }