Neovim: Add ai coding companion using remote ollama
This commit is contained in:
parent
6022c73977
commit
519d42bbe7
@ -240,6 +240,7 @@ require('lazy').setup({
|
|||||||
|
|
||||||
-- Document existing key chains
|
-- Document existing key chains
|
||||||
require('which-key').register {
|
require('which-key').register {
|
||||||
|
['<leader>a'] = { name = '[A]i', _ = 'which_key_ignore' },
|
||||||
['<leader>c'] = { name = '[C]ode', _ = 'which_key_ignore' },
|
['<leader>c'] = { name = '[C]ode', _ = 'which_key_ignore' },
|
||||||
['<leader>d'] = { name = '[D]ocument', _ = 'which_key_ignore' },
|
['<leader>d'] = { name = '[D]ocument', _ = 'which_key_ignore' },
|
||||||
['<leader>r'] = { name = '[R]ename', _ = 'which_key_ignore' },
|
['<leader>r'] = { name = '[R]ename', _ = 'which_key_ignore' },
|
||||||
@ -252,6 +253,7 @@ require('lazy').setup({
|
|||||||
}
|
}
|
||||||
-- visual mode
|
-- visual mode
|
||||||
require('which-key').register({
|
require('which-key').register({
|
||||||
|
['<leader>a'] = { '[A]i' },
|
||||||
['<leader>h'] = { 'Git [H]unk' },
|
['<leader>h'] = { 'Git [H]unk' },
|
||||||
}, { mode = 'v' })
|
}, { mode = 'v' })
|
||||||
end,
|
end,
|
||||||
|
93
nvim/lua/custom/plugins/codecompanion.lua
Normal file
93
nvim/lua/custom/plugins/codecompanion.lua
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
-- AI-powered coding
|
||||||
|
-- https://github.com/olimorris/codecompanion.nvim
|
||||||
|
return {
|
||||||
|
'olimorris/codecompanion.nvim',
|
||||||
|
dependencies = {
|
||||||
|
'nvim-lua/plenary.nvim',
|
||||||
|
'nvim-treesitter/nvim-treesitter',
|
||||||
|
'hrsh7th/nvim-cmp', -- Optional: For using slash commands and variables in the chat buffer
|
||||||
|
'nvim-telescope/telescope.nvim', -- Optional: For using slash commands
|
||||||
|
{ 'stevearc/dressing.nvim', opts = {} }, -- Optional: Improves the default Neovim UI
|
||||||
|
},
|
||||||
|
keys = {
|
||||||
|
{ '<leader>aa', '<cmd>CodeCompanionActions<CR>', desc = 'Actions' },
|
||||||
|
{ '<leader>at', '<cmd>CodeCompanionToggle<CR>', desc = 'Toggle chat' },
|
||||||
|
{ '<leader>aA', '<cmd>CodeCompanionAdd<CR>', desc = 'Add to chat', mode = 'v' },
|
||||||
|
{ '<leader>ax', '<cmd>CodeCompanion /explain<CR>', desc = 'Explain', mode = '' },
|
||||||
|
{ '<leader>af', '<cmd>CodeCompanion /fix<CR>', desc = 'Fix', mode = 'v' },
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
require('codecompanion').setup {
|
||||||
|
strategies = {
|
||||||
|
chat = {
|
||||||
|
adapter = 'codellama_direct',
|
||||||
|
},
|
||||||
|
inline = {
|
||||||
|
adapter = 'codellama_direct',
|
||||||
|
},
|
||||||
|
agent = {
|
||||||
|
adapter = 'codellama_direct',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
adapters = {
|
||||||
|
-- Not working yet to go through openwebui. Only works when connecting directly to ollama.
|
||||||
|
ollama = function()
|
||||||
|
return require('codecompanion.adapters').extend('ollama', {
|
||||||
|
env = {
|
||||||
|
url = 'https://openwebui.grosinger.net/ollama',
|
||||||
|
api_key = 'cmd:cat /home/tgrosinger/.openwebui',
|
||||||
|
},
|
||||||
|
headers = {
|
||||||
|
['Content-Type'] = 'application/json',
|
||||||
|
['Authorization'] = 'Bearer ${api_key}',
|
||||||
|
},
|
||||||
|
parameters = {
|
||||||
|
sync = true,
|
||||||
|
},
|
||||||
|
schema = {
|
||||||
|
model = {
|
||||||
|
default = 'codellama:13b',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
codellama_direct = function()
|
||||||
|
return require('codecompanion.adapters').extend('ollama', {
|
||||||
|
env = {
|
||||||
|
url = 'http://192.168.1.66:11434',
|
||||||
|
},
|
||||||
|
headers = {
|
||||||
|
['Content-Type'] = 'application/json',
|
||||||
|
},
|
||||||
|
parameters = {
|
||||||
|
sync = true,
|
||||||
|
},
|
||||||
|
schema = {
|
||||||
|
model = {
|
||||||
|
default = 'codellama:13b',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
llama31_direct = function()
|
||||||
|
return require('codecompanion.adapters').extend('ollama', {
|
||||||
|
env = {
|
||||||
|
url = 'http://192.168.1.66:11434',
|
||||||
|
},
|
||||||
|
headers = {
|
||||||
|
['Content-Type'] = 'application/json',
|
||||||
|
},
|
||||||
|
parameters = {
|
||||||
|
sync = true,
|
||||||
|
},
|
||||||
|
schema = {
|
||||||
|
model = {
|
||||||
|
default = 'llama3.1:latest',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user