From 84e15f0e2091e3a89a2303dda12a3b5fde29d8cd Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Tue, 7 Oct 2025 20:52:59 -0700 Subject: [PATCH] Configure CodeCompanion plugin --- .config/nvim/lua/plugins/llm.lua | 125 +++++++++++++++++++++---------- 1 file changed, 84 insertions(+), 41 deletions(-) diff --git a/.config/nvim/lua/plugins/llm.lua b/.config/nvim/lua/plugins/llm.lua index 1a080a1..8b76856 100644 --- a/.config/nvim/lua/plugins/llm.lua +++ b/.config/nvim/lua/plugins/llm.lua @@ -1,43 +1,86 @@ return { - { - "github/copilot.vim", - config = function() - vim.keymap.set("n", "ce", ":Copilot enable", { desc = "Enable Copilot Completions" }) - vim.keymap.set("n", "cd", ":Copilot disable", { desc = "Disable Copilot Completions" }) - vim.keymap.set("i", "", "copilot#Accept()", { - expr = true, - silent = true, - replace_keycodes = false, - }) - vim.g.copilot_no_tab_map = true - end, - }, - { - "CopilotC-Nvim/CopilotChat.nvim", - tag = "v3.4.0", - dependencies = { - { "nvim-lua/plenary.nvim" }, - { "github/copilot.vim" }, - }, - build = "make tiktoken", - config = function() - vim.keymap.set("n", "cc", ":CopilotChatToggle", { desc = "Toggle Copilot Chat" }) - vim.keymap.set("n", "cx", ":CopilotChatReset", { desc = "Reset Copilot Chat" }) - require("CopilotChat").setup({ - question_header = "", - answer_header = "", - separator = "", - error_header = "> [!ERROR] Error", - window = { - layout = "horizontal", - height = 0.3, - width = 0.25, - }, - auto_insert_mode = false, - chat_autocomplete = false, - highlight_headers = false, - show_help = false, - }) - end, - }, + { + "github/copilot.vim", + config = function() + vim.keymap.set("n", "ce", ":Copilot enable", { desc = "Enable Copilot Completions" }) + vim.keymap.set("n", "cd", ":Copilot disable", { desc = "Disable Copilot Completions" }) + vim.keymap.set("i", "", "copilot#Accept()", { + expr = true, + silent = true, + replace_keycodes = false, + }) + vim.g.copilot_no_tab_map = true + end, + }, + { + "CopilotC-Nvim/CopilotChat.nvim", + tag = "v3.4.0", + dependencies = { + { "nvim-lua/plenary.nvim" }, + { "github/copilot.vim" }, + }, + build = "make tiktoken", + config = function() + -- vim.keymap.set("n", "cc", ":CopilotChatToggle", { desc = "Toggle Copilot Chat" }) + -- vim.keymap.set("n", "cx", ":CopilotChatReset", { desc = "Reset Copilot Chat" }) + require("CopilotChat").setup({ + question_header = "", + answer_header = "", + separator = "", + error_header = "> [!ERROR] Error", + window = { + layout = "horizontal", + height = 0.3, + width = 0.25, + }, + auto_insert_mode = false, + chat_autocomplete = false, + highlight_headers = false, + show_help = false, + }) + end, + }, + { + "olimorris/codecompanion.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "franco-ruggeri/codecompanion-spinner.nvim", + }, + config = function() + vim.keymap.set("n", "cc", ":CodeCompanionChat Toggle", { desc = "Toggle CodeCompanion Chat" }) + vim.keymap.set("v", "cc", ":CodeCompanionChat Add", { desc = "Add Context to CodeCompanion Chat" }) + vim.keymap.set( + "n", + "cx", + ":CodeCompanion chat clear", + { desc = "Clear CodeCompanion Chat History" } + ) + + require("codecompanion").setup({ + strategies = { + chat = { + adapter = "copilot", + model = "claude-3.5-sonnet", + }, + }, + extensions = { + spinner = {}, + }, + display = { + action_palette = { + width = 95, + height = 10, + prompt = "Prompt ", -- Prompt used for interactive LLM calls + provider = "default", + opts = { + show_default_actions = true, -- Show the default actions in the action palette? + show_default_prompt_library = true, -- Show the default prompt library in the action palette? + title = "CodeCompanion actions", -- The title of the action palette + }, + }, + }, + log_level = "DEBUG", + }) + end, + }, }