add codecompanion with inline via openai + chat via ollama

This commit is contained in:
Carlos Sousa 2025-05-08 01:53:21 +02:00
parent 6fd8d8847b
commit 9f7550464b
3 changed files with 66 additions and 0 deletions

2
config/nvim/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
# secrets for nvim
lua/secrets/*.lua

View File

@ -0,0 +1,61 @@
local secrets = require('secrets.codecompanion')
return {
"olimorris/codecompanion.nvim",
opts = {
strategies = {
-- Change Default Adapter
chat = {
adapter = "ollama",
},
inline = {
adapter = "openai_41mini",
keymaps = {
accept_change = {
modes = { n = "ga" },
description = "Accept the suggested change",
},
reject_change = {
modes = { n = "gr" },
description = "Reject the suggested change",
},
},
},
},
adapters = {
openai_41mini = function()
return require("codecompanion.adapters").extend("openai", {
name = "openai_41mini",
schema = {
model = {
default = "gpt-4.1-mini"
}
},
env = {
api_key = secrets.openai_api_key
}
})
end,
ollama = function()
return require("codecompanion.adapters").extend("ollama", {
name = "local_llama3.2",
schema = {
model = {
default = "llama3.2:3b"
},
num_ctx = {
default = 16384,
},
num_predict = {
default = -1,
},
},
})
end,
},
},
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-treesitter/nvim-treesitter",
},
}

View File

@ -0,0 +1,3 @@
return {
openai_api_key = "your_own_api_key"
}