feat: codecompanion.nvim

This commit is contained in:
iofq 2025-02-06 02:48:48 -06:00
parent 55bade6fb7
commit b4404d2c1f
6 changed files with 69 additions and 46 deletions

12
flake.lock generated
View file

@ -139,11 +139,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1738410390, "lastModified": 1738680400,
"narHash": "sha256-xvTo0Aw0+veek7hvEVLzErmJyQkEcRk6PSR4zsRQFEc=", "narHash": "sha256-ooLh+XW8jfa+91F1nhf9OF7qhuA/y1ChLx6lXDNeY5U=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "3a228057f5b619feb3186e986dbe76278d707b6e", "rev": "799ba5bffed04ced7067a91798353d360788b30d",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -167,11 +167,11 @@
}, },
"nixpkgs-master": { "nixpkgs-master": {
"locked": { "locked": {
"lastModified": 1738557153, "lastModified": 1738831044,
"narHash": "sha256-KbuxOVz6SCBCkjJufqmdhItzhf8OCBKnRP+JWE9EFlo=", "narHash": "sha256-6y2I2h4hX8d+LXLCzgu7QJ3Wvkx89R0x3WFQ5ovhwco=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "3d89be6655a3ca15643456199b491b524929f61c", "rev": "e4b6440d7ca1649bb95bd59f39b2279db959e498",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -14,11 +14,11 @@ with final.pkgs.lib; let
all-plugins = with pkgs.vimPlugins; [ all-plugins = with pkgs.vimPlugins; [
aerial-nvim aerial-nvim
avante-nvim
inputs.nixpkgs-master.legacyPackages.${pkgs.system}.vimPlugins.blink-cmp inputs.nixpkgs-master.legacyPackages.${pkgs.system}.vimPlugins.blink-cmp
blink-cmp-copilot blink-cmp-copilot
blink-compat blink-compat
blink-ripgrep-nvim blink-ripgrep-nvim
codecompanion-nvim
copilot-lua copilot-lua
diffview-nvim diffview-nvim
eyeliner-nvim eyeliner-nvim

View file

@ -2,10 +2,19 @@ return {
{ {
"zbirenbaum/copilot.lua", "zbirenbaum/copilot.lua",
cmd = "Copilot", cmd = "Copilot",
keys = {
{
'M-\\',
'<cmd>Copilot panel<CR>',
noremap = true,
desc = 'Copilot panel'
}
},
opts = { opts = {
panel = { enabled = false }, panel = { enabled = true, keymap = { accept = "ga" } },
suggestion = { suggestion = {
enabled = true, enabled = true,
auto_trigger = true,
keymap = { keymap = {
accept = "<M-]>", accept = "<M-]>",
next = "<M-[>", next = "<M-[>",
@ -43,36 +52,50 @@ return {
} }
}, },
{ {
"yetone/avante.nvim", "olimorris/codecompanion.nvim",
cmd = "Copilot", cmd = "Copilot",
dependencies = { dependencies = {
"stevearc/dressing.nvim",
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",
"MunifTanjim/nui.nvim", "nvim-treesitter/nvim-treesitter",
"zbirenbaum/copilot.lua", "zbirenbaum/copilot.lua",
},
opts = {
adapters = {
copilot = function()
return require("codecompanion.adapters").extend("copilot", {
name = "copilot-claude-3.5-sonnet",
schema = { model = "claude-3.5-sonnet", },
})
end
},
strategies = {
chat = { adapter = "copilot-claude-3.5-sonnet", },
inline = { adapter = "copilot-claude-3.5-sonnet", },
},
},
init = function()
vim.api.nvim_create_user_command('CC', ':CodeCompanion', {})
end,
keys = {
{ {
'MeanderingProgrammer/render-markdown.nvim', '<leader>ac',
opts = { '<cmd>CodeCompanionChat Toggle<CR>',
file_types = { "markdown", "Avante" }, noremap = true,
desc = 'Copilot chat toggle'
}, },
ft = { "markdown", "Avante" }, {
'<leader>as',
'<cmd>CodeCompanionChat Add<CR>',
noremap = true,
desc = 'Copilot chat add selection'
}, },
}, {
opts = { '<leader>aa',
provider = "copilot", '<cmd>CodeCompanionActions<CR>',
-- auto_suggestions_provider = "copilot", noremap = true,
behavior = { desc = 'Copilot inline'
auto_suggestions = false, -- TODO
},
file_selector = {
provider = "native", -- TODO snacks once it's ready
},
windows = {
width = 50,
ask = {
floating = true
}
}
} }
} }
},
} }

View file

@ -3,7 +3,6 @@ return {
'saghen/blink.cmp', 'saghen/blink.cmp',
event = "VeryLazy", event = "VeryLazy",
dependencies = { dependencies = {
{ "yetone/avante.nvim", lazy = true },
'saghen/blink.compat', 'saghen/blink.compat',
'rafamadriz/friendly-snippets', 'rafamadriz/friendly-snippets',
'giuxtaposition/blink-cmp-copilot', 'giuxtaposition/blink-cmp-copilot',
@ -34,8 +33,7 @@ return {
"snippets", "snippets",
"buffer", "buffer",
"ripgrep", "ripgrep",
"avante_commands", "copilot"
"avante_mentions",
}, },
providers = { providers = {
ripgrep = { ripgrep = {
@ -43,18 +41,12 @@ return {
name = "rg", name = "rg",
score_offset = -10, score_offset = -10,
}, },
avante_commands = { copilot = {
name = "avante_commands", name = "copilot",
module = "blink.compat.source", module = "blink-cmp-copilot",
score_offset = 90, score_offset = 100,
opts = {}, async = true,
}, },
avante_mentions = {
name = "avante_mentions",
module = "blink.compat.source",
score_offset = 1000,
opts = {},
}
} }
}, },
keymap = { keymap = {
@ -77,6 +69,8 @@ return {
} }
}, },
menu = { menu = {
-- auto show in cmdline
auto_show = true,
draw = { draw = {
treesitter = { "lsp" }, treesitter = { "lsp" },
columns = { columns = {

View file

@ -7,7 +7,8 @@ return {
{ {
'<leader>de', '<leader>de',
'<cmd>Trouble diagnostics toggle focus=true<CR>', '<cmd>Trouble diagnostics toggle focus=true<CR>',
{ noremap = true, desc = 'Trouble diagnostics' } noremap = true,
desc = 'Trouble diagnostics'
} }
} }
}, },

View file

@ -164,10 +164,15 @@ return {
ring = { ring = {
storage = "memory", storage = "memory",
}, },
picker = {
select = {
action = require('yanky.picker').actions.set_register("+")
}
}
}, },
keys = { keys = {
{ "y", "<Plug>(YankyYank)", mode = { "n", "x" } }, { "y", "<Plug>(YankyYank)", mode = { "n", "x" } },
{ "<leader>fp", "<cmd>YankyRingHistory<cr>", { mode = { "n", "x" }, noremap = true, silent = true, desc = 'Pick history (yanky.nvim)' } } { "<leader>fp", "<cmd>YankyRingHistory<cr>", mode = { "n", "x" }, noremap = true, silent = true, desc = 'Pick history (yanky.nvim)' }
}, },
}, },
} }