From 4e5dc8d8987871ef36ad3b1a1f07eaf356aa4aff Mon Sep 17 00:00:00 2001 From: Xavier Logerais Date: Fri, 4 Jul 2025 00:30:50 +0200 Subject: [PATCH] feat: Add plugin olimorris/codecompanion.nvim --- lua/plugins/codecompanion.lua | 62 +++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 lua/plugins/codecompanion.lua diff --git a/lua/plugins/codecompanion.lua b/lua/plugins/codecompanion.lua new file mode 100644 index 0000000..d7cd890 --- /dev/null +++ b/lua/plugins/codecompanion.lua @@ -0,0 +1,62 @@ +local prefix = "A" + +---@type LazySpec +return { + { + "olimorris/codecompanion.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-treesitter/nvim-treesitter", + { + "AstroNvim/astrocore", + ---@param opts AstroCoreOpts + opts = function(_, opts) + if not opts.mappings then opts.mappings = {} end + + opts.mappings.n[prefix] = { desc = require("astroui").get_icon("CodeCompanion", 1, true) .. "CodeCompanion" } + opts.mappings.v[prefix] = { desc = require("astroui").get_icon("CodeCompanion", 1, true) .. "CodeCompanion" } + + opts.mappings.n[prefix .. "c"] = { "CodeCompanionChat Toggle", desc = "Toggle chat" } + opts.mappings.v[prefix .. "c"] = { "CodeCompanionChat Toggle", desc = "Toggle chat" } + + opts.mappings.n[prefix .. "p"] = { "CodeCompanionActions", desc = "Open action palette" } + opts.mappings.v[prefix .. "p"] = { "CodeCompanionActions", desc = "Open action palette" } + + opts.mappings.n[prefix .. "q"] = { "CodeCompanion", desc = "Open inline assistant" } + opts.mappings.v[prefix .. "q"] = { "CodeCompanion", desc = "Open inline assistant" } + + opts.mappings.v[prefix .. "a"] = { "CodeCompanionChat Add", desc = "Add selection to chat" } + + -- Expand cc to CodeCompanion in cmdline mode + vim.cmd [[cab cc CodeCompanion]] + end, + }, + { "AstroNvim/astroui", opts = { icons = { CodeCompanion = "󱙺" } } }, + }, + event = "User AstroFile", + cmd = { + "CodeCompanion", + "CodeCompanionActions", + "CodeCompanionChat", + "CodeCompanionCmd", + }, + opts = { + strategies = { + chat = { + adapter = "mistral", + }, + inline = { + adapter = "mistral", + }, + }, + }, + }, + { + "MeanderingProgrammer/render-markdown.nvim", + optional = true, + opts = function(_, opts) + if not opts.file_types then opts.file_types = { "markdown" } end + opts.file_types = require("astrocore").list_insert_unique(opts.file_types, { "codecompanion" }) + end, + }, +}