From 352a8c3c97a3d0cf3951e9e84a61ab1a0caf006e Mon Sep 17 00:00:00 2001 From: Dmitry Chumak Date: Wed, 23 Apr 2025 21:20:22 +0300 Subject: [PATCH] [nvim] codecompanion plugin --- nvim/lazy-lock.json | 2 ++ nvim/lua/plugins/codecompanion.lua | 37 ++++++++++++++++++++++++++++++ nvim/lua/plugins/init.lua | 9 ++++++++ 3 files changed, 48 insertions(+) create mode 100644 nvim/lua/plugins/codecompanion.lua diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index 112d8c7..53c440b 100644 --- a/nvim/lazy-lock.json +++ b/nvim/lazy-lock.json @@ -3,6 +3,7 @@ "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-nvim-lsp": { "branch": "main", "commit": "99290b3ec1322070bcfb9e846450a46f6efa50f0" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "codecompanion.nvim": { "branch": "main", "commit": "1b1bfc71f426a50ece54489078f5afe82b0af90c" }, "github-theme": { "branch": "main", "commit": "c106c9472154d6b2c74b74565616b877ae8ed31d" }, "gitsigns.nvim": { "branch": "main", "commit": "011dc6718bcebdf92a5336bb0da79189c3afe621" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, @@ -10,6 +11,7 @@ "mason.nvim": { "branch": "main", "commit": "fc98833b6da5de5a9c5b1446ac541577059555be" }, "nvim-cmp": { "branch": "main", "commit": "c27370703e798666486e3064b64d59eaf4bdc6d5" }, "nvim-lspconfig": { "branch": "master", "commit": "fd26f8626c03b424f7140d454031d1dcb8d23513" }, + "nvim-treesitter": { "branch": "master", "commit": "684eeac91ed8e297685a97ef70031d19ac1de25a" }, "outline.nvim": { "branch": "main", "commit": "ae473fb51b7b6086de0876328c81a63f9c3ecfef" }, "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, "telescope-file-browser.nvim": { "branch": "master", "commit": "626998e5c1b71c130d8bc6cf7abb6709b98287bb" }, diff --git a/nvim/lua/plugins/codecompanion.lua b/nvim/lua/plugins/codecompanion.lua new file mode 100644 index 0000000..7c1b4f6 --- /dev/null +++ b/nvim/lua/plugins/codecompanion.lua @@ -0,0 +1,37 @@ +require("codecompanion").setup({ + strategies = { + chat = { + adapter = "deepseek", + }, + inline = { + adapter = "deepseek", + }, + cmd = { + adapter = "deepseek", + } + }, + adapters = { + deepseek = function() + return require("codecompanion.adapters").extend("deepseek", { + env = { + api_key = (function() + local path = os.getenv("HOME") .. "/.config/deepseek_api_key" + local file = io.open(path, "r") + if not file then + vim.notify("Deepseek API key not found at " .. path, vim.log.levels.WARN) + return nil + end + local content = file:read("*a"):gsub("%s+", "") + file:close() + return content + end)(), + }, + schema = { + model = { + default = "deepseek-chat", + }, + }, + }) + end, + }, +}) diff --git a/nvim/lua/plugins/init.lua b/nvim/lua/plugins/init.lua index 2f53025..a9adf06 100644 --- a/nvim/lua/plugins/init.lua +++ b/nvim/lua/plugins/init.lua @@ -84,6 +84,14 @@ local plugins = { -- Your setup opts here }, }, + { + "olimorris/codecompanion.nvim", + opts = {}, + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-treesitter/nvim-treesitter", + }, + }, } require("lazy").setup(plugins) @@ -96,3 +104,4 @@ vim.cmd([[ require("plugins/telescope") require("plugins/completions") require("plugins/gitsigns") +require("plugins/codecompanion")