diff --git a/lua/shelbybark/plugins/codecompanion.lua b/lua/shelbybark/plugins/codecompanion.lua new file mode 100644 index 0000000..b56d1d0 --- /dev/null +++ b/lua/shelbybark/plugins/codecompanion.lua @@ -0,0 +1,63 @@ +return { + "olimorris/codecompanion.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-treesitter/nvim-treesitter", + -- Optional: for enhanced diagnostics/context + "georgeharker/mcp-diagnostics.nvim", + }, + event = "VeryLazy", -- Lazy load the plugin + config = function() + require("codecompanion").setup({ + ignore_warnings = true, + strategies = { + chat = { + adapter = "anthropic", + }, + inline = { + adapter = "anthropic", + }, + }, + adapters = { + http = { + anthropic = function() + return require("codecompanion.adapters").extend("anthropic", { + env = { + api_key = "ANTHROPIC_API_KEY", + }, + schema = { + model = { + default = "claude-sonnet-4-20250514", + }, + }, + }) + end, + }, + }, + -- Display settings for the chat window + display = { + chat = { + window = { + layout = "vertical", -- or "horizontal", "float" + }, + }, + }, + }) + + -- Optional: Set up keymaps + vim.api.nvim_set_keymap( + "n", + "cc", + "CodeCompanionChat Toggle", + { noremap = true, silent = true } + ) + vim.api.nvim_set_keymap( + "v", + "cc", + "CodeCompanionChat Toggle", + { noremap = true, silent = true } + ) + vim.api.nvim_set_keymap("n", "ca", "CodeCompanionActions", { noremap = true, silent = true }) + vim.api.nvim_set_keymap("v", "ca", "CodeCompanionActions", { noremap = true, silent = true }) + end, +}