-- 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 = { { 'aa', 'CodeCompanionActions', desc = 'Actions' }, { 'at', 'CodeCompanionToggle', desc = 'Toggle chat' }, { 'aA', 'CodeCompanionAdd', desc = 'Add to chat', mode = 'v' }, { 'ax', 'CodeCompanion /explain', desc = 'Explain', mode = '' }, { 'af', 'CodeCompanion /fix', 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, }