From ec01d807a0ea1a7eec8bf31a9cc80d9e9cd19615 Mon Sep 17 00:00:00 2001 From: "RingOfStorms (Joshua Bell)" Date: Tue, 12 Nov 2024 10:28:18 -0600 Subject: [PATCH] add copilot chat --- flake.lock | 17 ++++++++ flake.nix | 3 ++ lua/plugins/cmp_autocompletion.lua | 70 ++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+) diff --git a/flake.lock b/flake.lock index ca6e515..a2a4cdf 100644 --- a/flake.lock +++ b/flake.lock @@ -48,6 +48,22 @@ "type": "github" } }, + "nvim_plugin-CopilotC-Nvim/CopilotChat.nvim": { + "flake": false, + "locked": { + "lastModified": 1730902338, + "narHash": "sha256-kM9PtMEKyMkJjSsnwSELx52Dx6Va1id92Svv7w6nVtc=", + "owner": "CopilotC-Nvim", + "repo": "CopilotChat.nvim", + "rev": "18d51754e9dc87d6b85f1e331c1fca0825384517", + "type": "github" + }, + "original": { + "owner": "CopilotC-Nvim", + "repo": "CopilotChat.nvim", + "type": "github" + } + }, "nvim_plugin-JoosepAlviste/nvim-ts-context-commentstring": { "flake": false, "locked": { @@ -885,6 +901,7 @@ "nixpkgs": "nixpkgs", "nixpkgs-stable": "nixpkgs-stable", "nvim_plugin-Almo7aya/openingh.nvim": "nvim_plugin-Almo7aya/openingh.nvim", + "nvim_plugin-CopilotC-Nvim/CopilotChat.nvim": "nvim_plugin-CopilotC-Nvim/CopilotChat.nvim", "nvim_plugin-JoosepAlviste/nvim-ts-context-commentstring": "nvim_plugin-JoosepAlviste/nvim-ts-context-commentstring", "nvim_plugin-L3MON4D3/LuaSnip": "nvim_plugin-L3MON4D3/LuaSnip", "nvim_plugin-MeanderingProgrammer/render-markdown.nvim": "nvim_plugin-MeanderingProgrammer/render-markdown.nvim", diff --git a/flake.nix b/flake.nix index 372bdf5..4c53868 100644 --- a/flake.nix +++ b/flake.nix @@ -106,6 +106,8 @@ "nvim_plugin-zbirenbaum/copilot-cmp".flake = false; "nvim_plugin-zbirenbaum/copilot.lua".url = "github:zbirenbaum/copilot.lua"; "nvim_plugin-zbirenbaum/copilot.lua".flake = false; + "nvim_plugin-CopilotC-Nvim/CopilotChat.nvim".url = "github:CopilotC-Nvim/CopilotChat.nvim"; + "nvim_plugin-CopilotC-Nvim/CopilotChat.nvim".flake = false; # "nvim_plugin-yetone/avante.nvim".url = "github:yetone/avante.nvim"; # "nvim_plugin-yetone/avante.nvim".flake = false; # "nvim_plugin-stevearc/dressing.nvim".url = "github:stevearc/dressing.nvim"; @@ -203,6 +205,7 @@ rustywind markdownlint-cli2 # LSPs + python312Packages.tiktoken # needed for copilot chat nil # nix lua-language-server vscode-langservers-extracted # HTML/CSS/JSON/ESLint diff --git a/lua/plugins/cmp_autocompletion.lua b/lua/plugins/cmp_autocompletion.lua index 1217474..d9acf2a 100644 --- a/lua/plugins/cmp_autocompletion.lua +++ b/lua/plugins/cmp_autocompletion.lua @@ -26,6 +26,74 @@ return { main = "copilot", }, { "zbirenbaum/copilot-cmp", opts = {}, main = "copilot_cmp" }, + { + "CopilotC-Nvim/CopilotChat.nvim", + branch = "canary", + dependencies = { + { "zbirenbaum/copilot.lua" }, -- or github/copilot.vim + { "nvim-lua/plenary.nvim" }, -- for curl, log wrapper + }, + opts = { + -- debug = true, -- Enable debugging + -- See Configuration section for rest + mappings = { + complete = { + insert = "", + }, + }, + window = { + layout = "float", + relative = "cursor", + width = 1, + height = 0.4, + row = 1, + }, + }, + keys = { + -- Show help actions with telescope + { + "h", + function() + local actions = require("CopilotChat.actions") + require("CopilotChat.integrations.telescope").pick(actions.help_actions()) + end, + desc = "CopilotChat - Help actions", + mode = { "n", "v", "x" }, + }, + -- Show prompts actions with telescope + { + "p", + function() + local actions = require("CopilotChat.actions") + require("CopilotChat.integrations.telescope").pick(actions.prompt_actions()) + end, + desc = "CopilotChat - Prompt actions", + mode = { "n", "v", "x" }, + }, + -- Quick chat with Copilot + { + "q", + function() + local input = vim.fn.input("Quick Chat: ") + if input ~= "" then + require("CopilotChat").ask(input, { selection = require("CopilotChat.select").buffer }) + end + end, + desc = "CopilotChat - Quick chat", + mode = { "n", "v", "x" }, + }, + -- Quick chat with Copilot + { + "c", + function() + require("CopilotChat").toggle() + end, + desc = "CopilotChat - Toggle", + mode = { "n", "v", "x" }, + }, + }, + -- See Commands section for default commands if you want to lazy load on them + }, }, config = function() -- See `:help cmp` @@ -104,5 +172,7 @@ return { { name = "crates" }, }, }) + + require("CopilotChat.integrations.cmp").setup() end, }