aboutsummaryrefslogtreecommitdiffstats
path: root/lua/plugins/codecompanion.lua
diff options
context:
space:
mode:
authorElvis Claros Castro <elvis@claros.ar>2025-10-30 16:32:45 -0300
committerElvis Claros Castro <elvis@claros.ar>2025-10-30 16:32:45 -0300
commit3bcc0dfc274eaa46d9df4c5952d6b30a7e1a0131 (patch)
treecdcca5f32e19f979f08ebf5844e9b46d5c285021 /lua/plugins/codecompanion.lua
parent64402794cfb767f9d579b0cef0e3bd9bcf062131 (diff)
downloadnvim-conf-3bcc0dfc274eaa46d9df4c5952d6b30a7e1a0131.tar.gz
nvim-conf-3bcc0dfc274eaa46d9df4c5952d6b30a7e1a0131.zip
elimino zfz
Diffstat (limited to 'lua/plugins/codecompanion.lua')
-rw-r--r--lua/plugins/codecompanion.lua111
1 files changed, 107 insertions, 4 deletions
diff --git a/lua/plugins/codecompanion.lua b/lua/plugins/codecompanion.lua
index ddd209b..ff00936 100644
--- a/lua/plugins/codecompanion.lua
+++ b/lua/plugins/codecompanion.lua
@@ -6,8 +6,9 @@ return {
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-treesitter/nvim-treesitter",
- "ibhagwan/fzf-lua", -- For fzf provider, file or buffer picker
+ "nvim-telescope/telescope.nvim", -- Using telescope for file and buffer picker
"jellydn/spinner.nvim", -- Show loading spinner when request is started
+ "ravitemer/codecompanion-history.nvim", -- History management extension
{
"echasnovski/mini.diff",
config = function()
@@ -75,7 +76,7 @@ return {
gemini = function()
return require("codecompanion.adapters").extend("gemini", {
env = {
- api_key = "cmd:op read op://personal/Gemini_API/credential --no-newline",
+ api_key = "cmd:echo $GEMINI_API_KEY",
},
})
end,
@@ -95,7 +96,7 @@ return {
},
})
end,
- openai_compatible = function()
+ openai_compatible_llama_cpp = function()
return require("codecompanion.adapters").extend("openai_compatible", {
env = {
api_key = "cmd:echo $OPENAI_API_KEY",
@@ -114,6 +115,27 @@ return {
},
})
end,
+
+ openai_compatible_qwen3_coder = function()
+ return require("codecompanion.adapters").extend("openai_compatible", {
+ env = {
+ api_key = "cmd:echo $DASHSCOPE_API_KEY",
+ chat_url = "/v1/chat/completions",
+ url = "https://dashscope-intl.aliyuncs.com/compatible-mode",
+ },
+ headers = {
+ ["Content-Type"] = "application/json",
+ },
+ schema = {
+ model = {
+ default = function()
+ return "qwen3-coder-plus"
+ end,
+ },
+ },
+ })
+ end,
+
xai = function()
return require("codecompanion.adapters").extend("xai", {
env = {
@@ -143,7 +165,7 @@ return {
},
strategies = {
chat = {
- adapter = "copilot",
+ adapter = "openai_compatible_qwen3_coder",
-- roles = { llm = " Copilot Chat", user = "IT Man" },
},
inline = { adapter = "copilot" },
@@ -166,6 +188,87 @@ return {
show_result_in_chat = true,
},
},
+ history = {
+ enabled = true,
+ opts = {
+ -- Keymap to open history from chat buffer (default: gh)
+ keymap = "gh",
+ -- Keymap to save the current chat manually (when auto_save is disabled)
+ save_chat_keymap = "sc",
+ -- Save all chats by default (disable to save only manually using 'sc')
+ auto_save = true,
+ -- Number of days after which chats are automatically deleted (0 to disable)
+ expiration_days = 0,
+ -- Picker interface (auto resolved to a valid picker)
+ picker = "telescope", -- ("telescope", "snacks", "fzf-lua", or "default")
+ -- Optional filter function to control which chats are shown when browsing
+ chat_filter = nil, -- function(chat_data) return boolean end
+ -- Customize picker keymaps (optional)
+ picker_keymaps = {
+ rename = { n = "r", i = "<M-r>" },
+ delete = { n = "d", i = "<M-d>" },
+ duplicate = { n = "<C-y>", i = "<C-y>" },
+ },
+ -- Automatically generate titles for new chats
+ auto_generate_title = true,
+ title_generation_opts = {
+ -- Adapter for generating titles (defaults to current chat adapter)
+ adapter = "copilot", -- Use copilot for cheaper title generation
+ -- Model for generating titles (defaults to current chat model)
+ model = "gpt-4.1", -- Use cheaper model for titles
+ -- Number of user prompts after which to refresh the title (0 to disable)
+ refresh_every_n_prompts = 3, -- Refresh after every 3rd user prompt
+ -- Maximum number of times to refresh the title (default: 3)
+ max_refreshes = 5,
+ format_title = function(original_title)
+ -- Custom formatting for titles
+ return original_title
+ end,
+ },
+ -- On exiting and entering neovim, loads the last chat on opening chat
+ continue_last_chat = false,
+ -- When chat is cleared with `gx` delete the chat from history
+ delete_on_clearing_chat = false,
+ -- Directory path to save the chats
+ dir_to_save = vim.fn.stdpath "data" .. "/codecompanion-history",
+ -- Enable detailed logging for history extension
+ enable_logging = false,
+
+ -- Summary system
+ summary = {
+ -- Keymap to generate summary for current chat (default: "gcs")
+ create_summary_keymap = "gcs",
+ -- Keymap to browse summaries (default: "gbs")
+ browse_summaries_keymap = "gbs",
+ generation_opts = {
+ adapter = "copilot", -- Use copilot for cheaper summary generation
+ model = "gpt-4.1", -- Use cheaper model for summaries
+ context_size = 90000, -- max tokens that the model supports
+ include_references = true, -- include slash command content
+ include_tool_outputs = true, -- include tool execution results
+ system_prompt = nil, -- custom system prompt (string or function)
+ format_summary = nil, -- custom function to format generated summary
+ },
+ },
+
+ -- Memory system (requires VectorCode CLI)
+ memory = {
+ -- Automatically index summaries when they are generated
+ auto_create_memories_on_summary_generation = false, -- Disabled by default
+ -- Path to the VectorCode executable
+ vectorcode_exe = "vectorcode",
+ -- Tool configuration
+ tool_opts = {
+ -- Default number of memories to retrieve
+ default_num = 10,
+ },
+ -- Enable notifications for indexing progress
+ notify = true,
+ -- Index all existing memories on startup
+ index_on_startup = false,
+ },
+ },
+ },
},
}
-- Show loading spinner when request is started