From 552b3e1a799929b7e43c1f0fe08b63077cc4be2f Mon Sep 17 00:00:00 2001 From: venus Date: Sat, 6 Jun 2026 01:56:41 -0500 Subject: [PATCH] Implemented chat and inline functionality with codecompanion!! --- lazy-lock.json | 2 +- lua/keybinds.lua | 14 +++----- lua/options.lua | 4 +-- lua/plugins/codecompanion.lua | 67 ++++++++++++++++++++++++++++++----- lua/plugins/remote.lua | 17 ++++++--- 5 files changed, 77 insertions(+), 27 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 76965e2..07e6ce5 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -7,7 +7,6 @@ "conform.nvim": { "branch": "master", "commit": "619363c30309d29ffa631e67c8183f2a72caa373" }, "dashboard-nvim": { "branch": "master", "commit": "f787e3462c2ee2b6117b17c1aa4ddf66cb6f57fe" }, "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, - "distant.nvim": { "branch": "v0.3", "commit": "67d6b066e8490725718b79f643966f4eafc7da3c" }, "fd": { "branch": "master", "commit": "f7d4d717c287a7834f8721efc0fa91c51d92afee" }, "fzf-lua": { "branch": "main", "commit": "988416cc782dfe28bff3f0da9b8c943b236cd86a" }, "gemini-cli.nvim": { "branch": "main", "commit": "c9fd62adda823628f5131a939d9c56ef7a898600" }, @@ -44,6 +43,7 @@ "obsidian.nvim": { "branch": "main", "commit": "239af7e896d1857d0a644253d2c7e571d38529a5" }, "plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" }, "presence.nvim": { "branch": "main", "commit": "87c857a56b7703f976d3a5ef15967d80508df6e6" }, + "remote-nvim.nvim": { "branch": "main", "commit": "9992c2fb8bf4f11aca2c8be8db286b506f92efcb" }, "render-markdown.nvim": { "branch": "main", "commit": "5adf0895310c1904e5abfaad40a2baad7fe44a07" }, "resize.nvim": { "branch": "main", "commit": "0b8943ef2ce54e65b9e56974e94dee593b28e7b5" }, "ripgrep": { "branch": "master", "commit": "48a6ad93f152dc848f1883ceb3bf2c7baab6738c" }, diff --git a/lua/keybinds.lua b/lua/keybinds.lua index 34bf370..becb2c3 100644 --- a/lua/keybinds.lua +++ b/lua/keybinds.lua @@ -56,18 +56,12 @@ vim.keymap.set("n","" ,"K" ,{ desc = "Move window to the upper -- vim.keymap.set("n", "a", ":IncRename ", {desc = 'ren[A]me variable under cursor'}) -- PLUGIN KEYBINDS -vim.keymap.set("n", "va" ,"CodeCompanionActions" ,{ desc = "Actions Panel", noremap = true, silent = true }) -vim.keymap.set("n", "vt" ,"CodeCompanionChat Toggle" ,{ desc = "Toggle Chat", noremap = true, silent = true }) -vim.keymap.set("v", "vg" ,"CodeCompanionChat Add" ,{ desc = "Add Chat", noremap = true, silent = true }) -vim.cmd([[cab cc CodeCompanion]]) - +vim.keymap.set({ "n", "v" } ,"aa" ,"CodeCompanionActions" ,{ desc = "CodeCompanion - Actions" }) +vim.keymap.set({ "n", "v" } ,"ac" ,"CodeCompanionChat Toggle" ,{ desc = "CodeCompanion - Chat" }) +vim.keymap.set({ "n", "v" } ,"ai" ,"CodeCompanion" ,{ desc = "CodeCompanion - Inline" }) +vim.keymap.set("v" ,"ad" ,"CodeCompanionChat Add" ,{ desc = "CodeCompanion - Add to Chat" }) -- Expand 'cc' into 'CodeCompanion' in the command line vim.cmd([[cab cc CodeCompanion]]) --- TODO better AI implementation -vim.keymap.set('n',"a/" ,"Gemini toggle" ,{ desc = "Toggle Gemini CLI" }) -vim.keymap.set('n',"aa" ,"Gemini toggle" ,{ desc = "Toggle Gemini CLI" }) -vim.keymap.set('n',"aq" ,"Gemini ask" ,{ desc = "Ask Gemini", }) -vim.keymap.set('n',"af" ,"Gemini add_file" ,{ desc = "Add File"} ) --spellcheck keybind to toggle on current buffer vim.keymap.set('n',"ze" ,"setlocal spell" ,{ desc = "enable spellecheck on buffer" }) diff --git a/lua/options.lua b/lua/options.lua index d9a41b8..e14d78d 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -37,8 +37,8 @@ vim.o.updatetime = 250 -- Decrease mapped sequence wait time vim.o.timeoutlen = 300 -- Configure how new splits should be opened --- vim.o.splitright = false --- vim.o.splitbelow = true +vim.o.splitright = true +vim.o.splitbelow = true vim.o.list = true vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } -- Preview substitutions live, as you type! diff --git a/lua/plugins/codecompanion.lua b/lua/plugins/codecompanion.lua index 562208c..b668b61 100644 --- a/lua/plugins/codecompanion.lua +++ b/lua/plugins/codecompanion.lua @@ -5,20 +5,69 @@ return { "nvim-treesitter/nvim-treesitter", }, opts = { - interactions = { + display = { chat = { - adapter = { - name = "gemini", - model = "gemini-3.5-flash", + window = { + layout = "vertical", + width = 0.35, + height = 0.35, + }, + keymaps = { + close = { + modes = { + n = "q", -- Bind "q" in normal mode to close the chat + }, + index = 1, + callback = "keymaps.close", + description = "Close Chat", + }, } }, - -- inline = { adapter = "gemini" }, - -- cmd = { adapter = "gemini" }, + }, + interactions = { + chat = { + adapter = "gemini_pro", -- Removed the curly braces + }, + inline = { + adapter = "gemini_flash", -- Removed the curly braces + }, }, background = { - adapter = { - name = "ollama", - model = "qwen-7b-instruct" + adapter = "ollama_bg", -- Pointed this to the new extended adapter string + }, + adapters = { + http = { + gemini_pro = function() + return require("codecompanion.adapters").extend("gemini", { + name = "gemini_pro", + schema = { + model = { + default = "gemini-3.5-flash", + }, + }, + }) + end, + gemini_flash = function() + return require("codecompanion.adapters").extend("gemini", { + name = "gemini_flash", + schema = { + model = { + default = "gemini-2.0-flash", + }, + }, + }) + end, + -- Added an extended Ollama adapter to fix your background task + ollama_bg = function() + return require("codecompanion.adapters").extend("ollama", { + name = "ollama_bg", + schema = { + model = { + default = "qwen-7b-instruct", + }, + }, + }) + end, }, }, } diff --git a/lua/plugins/remote.lua b/lua/plugins/remote.lua index 66661d6..5317d2c 100644 --- a/lua/plugins/remote.lua +++ b/lua/plugins/remote.lua @@ -1,7 +1,14 @@ return { - 'chipsenkbeil/distant.nvim', - branch = 'v0.3', - config = function() - require('distant'):setup() + "amitds1997/remote-nvim.nvim", + version = "*", -- Pin to GitHub releases for stability + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-telescope/telescope.nvim", + "MunifTanjim/nui.nvim", + }, + config = function() + require("remote-nvim").setup({ + ssh_config_file_paths = { vim.fn.expand("$HOME/.ssh/config") }, + }) end -} + }