diff --git a/.gitignore b/.gitignore index 92a49de..26f2283 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ nvim-pack-lock.json +.worktrees/ diff --git a/init.lua b/init.lua index cd28353..8539ffc 100644 --- a/init.lua +++ b/init.lua @@ -16,7 +16,8 @@ require("coc") -- ./lua/coc.lua require("treesitter") -- ./lua/treesitter.lua require("autocmds") -- ./lua/autocmds.lua require("diagnostics") -- ./lua/diagnostics.lua -require("avante_settings") -- ./lua/avante_settings.lua +require("codecompanion_settings") -- ./lua/codecompanion_settings.lua +require("corridor_settings") -- ./lua/corridor_settings.lua require('telescope_configuration') -- ./lua/telescope_configuration.lua require("mail") -- ./lua/mail.lua (no-op unless NEOMUTT=1) @@ -264,4 +265,3 @@ vim.api.nvim_create_autocmd("VimEnter", { end end, }) - diff --git a/lua/avante_settings.lua b/lua/avante_settings.lua deleted file mode 100644 index c66ffaf..0000000 --- a/lua/avante_settings.lua +++ /dev/null @@ -1,69 +0,0 @@ -require('avante').setup({ - instructions_file = "avante.md", - provider = "ollama", - providers = { - ollama = { - endpoint = "http://localhost:11434", - model = "codellama:latest", - }, - }, - behavior = { - auto_focus_sidebar = true, - auto_suggestions = true, -- Experimental. - jump_result_buffer_on_finish = false, - }, - windows = { - position = "right", - fillchars = "eob: ", - wrap = true, - width = 30, - height = 30, - sidebar_header = { - enabled = true, - align = "center", - rounded = true, - }, - spinner = { - editing = { - "⡀", - "⠄", - "⠂", - "⠁", - "⠈", - "⠐", - "⠠", - "⢀", - "⣀", - "⢄", - "⢂", - "⢁", - "⢈", - "⢐", - "⢠", - "⣠", - "⢤", - "⢢", - "⢡", - "⢨", - "⢰", - "⣰", - "⢴", - "⢲", - "⢱", - "⢸", - "⣸", - "⢼", - "⢺", - "⢹", - "⣹", - "⢽", - "⢻", - "⣻", - "⢿", - "⣿", - }, - generating = { "·", "✢", "✳", "∗", "✻", "✽" }, - thinking = { "🤯", "🙄" }, - }, - }, -}) diff --git a/lua/codecompanion_settings.lua b/lua/codecompanion_settings.lua new file mode 100644 index 0000000..388e6e3 --- /dev/null +++ b/lua/codecompanion_settings.lua @@ -0,0 +1,89 @@ +local adapters = require("codecompanion.adapters") + +require("codecompanion").setup({ + adapters = { + http = { + bifrost = function() + return adapters.extend("openai_compatible", { + name = "bifrost", + formatted_name = "Bifrost", + env = { + url = vim.env.BIFROST_BASE_URL or "https://bifrost.th3r00t.net", + api_key = vim.env.BIFROST_API_KEY + and "BIFROST_API_KEY" + or "file:~/.config/bifrost/api-key", + chat_url = "/v1/chat/completions", + models_endpoint = "/v1/models", + }, + schema = { + model = { + default = vim.env.CODECOMPANION_MODEL + or "OllamaMSI/qwen3:30b-a3b", + }, + }, + }) + end, + }, + }, + interactions = { + chat = { + adapter = "bifrost", + }, + inline = { + adapter = "bifrost", + }, + background = { + adapter = "bifrost", + }, + }, + display = { + action_palette = { + provider = "snacks", + }, + chat = { + window = { + layout = "vertical", + position = "right", + width = 0.42, + border = "rounded", + }, + start_in_insert_mode = false, + show_token_count = true, + }, + diff = { + enabled = true, + }, + }, + opts = { + log_level = "ERROR", + language = "English", + send_code = true, + }, +}) + +local map = vim.keymap.set +map({ "n", "v" }, "aa", "CodeCompanionActions", { + desc = "AI actions", +}) +map("n", "ac", "CodeCompanionChat Toggle", { + desc = "Toggle AI chat", +}) +map("n", "an", "CodeCompanionChat", { + desc = "New AI chat", +}) +map({ "n", "v" }, "ai", "CodeCompanion", { + desc = "AI inline prompt", +}) +map({ "n", "v" }, "ab", "CodeCompanionChat Add", { + desc = "Add buffer/selection to AI chat", +}) + +local which_key = require("which-key") +which_key.add({ + { "a", group = "AI" }, + { "aa", desc = "Actions" }, + { "ab", desc = "Add buffer/selection" }, + { "ac", desc = "Toggle chat" }, + { "ai", desc = "Inline prompt" }, + { "an", desc = "New chat" }, +}) diff --git a/lua/corridor_settings.lua b/lua/corridor_settings.lua new file mode 100644 index 0000000..a09a765 --- /dev/null +++ b/lua/corridor_settings.lua @@ -0,0 +1,47 @@ +local bifrost_endpoint = vim.env.BIFROST_COMPLETIONS_URL + or "https://bifrost.th3r00t.net/v1/completions" +local key_path = vim.fn.expand("~/.config/bifrost/api-key") +local key_file = io.open(key_path, "r") +local bifrost_api_key = key_file and vim.trim(key_file:read("*a")) or nil +if key_file then + key_file:close() +end + +require("corridor").setup({ + enabled = true, + provider = "lmstudio", -- OpenAI-compatible completions (Bifrost) + endpoint = bifrost_endpoint, + model = vim.env.CORRIDOR_MODEL or "OllamaMSI/qwen2.5-coder:7b", + api_key = vim.env.BIFROST_API_KEY or bifrost_api_key, + + debounce_ms = 400, + max_tokens = 64, + temperature = 0.1, + + -- CoC owns ; keep Corridor's mappings out of its way. + accept_keymap = "", + dismiss_keymap = "", + + max_context_lines = 256, + cross_file_context = true, + max_cross_file_lines = 100, + max_cross_file_count = 5, + + exclude_filetypes = { + "Avante", + "TelescopePrompt", + "help", + "lazy", + "mason", + "neo-tree", + "snacks_picker_input", + "terminal", + }, + + -- qwen2.5-coder FIM token order. + fim = { + prefix = "<|fim_prefix|>", + suffix = "<|fim_suffix|>", + middle = "<|fim_middle|>", + }, +}) diff --git a/lua/plugins.lua b/lua/plugins.lua index 63b670c..fe84557 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -61,7 +61,8 @@ vim.pack.add({ { src = "https://github.com/francoiscabrol/ranger.vim" }, { src = "https://github.com/folke/snacks.nvim" }, { src = "https://github.com/coder/claudecode.nvim" }, - { src = "https://github.com/yetone/avante.nvim" }, + { src = "https://github.com/olimorris/codecompanion.nvim" }, + { src = "https://github.com/orellazri/corridor.nvim" }, { src = "https://github.com/alaviss/nim.nvim" }, { src = "https://github.com/glebzlat/arduino-nvim" }, { src = "https://github.com/norcalli/nvim-colorizer.lua" }, @@ -422,5 +423,3 @@ require("remote-nvim").setup({ max_size = 1024 * 1024 * 2, -- 2MB }, }) - -