diff --git a/config/nvim/lazy-lock.json b/config/nvim/lazy-lock.json index 7171664..f9a1db0 100644 --- a/config/nvim/lazy-lock.json +++ b/config/nvim/lazy-lock.json @@ -1,6 +1,6 @@ { + "CopilotChat.nvim": { "branch": "canary", "commit": "df19e7ab15537436a26f59fa991f2fa81d847a0d" }, "LuaSnip": { "branch": "master", "commit": "ce0a05ab4e2839e1c48d072c5236cce846a387bc" }, - "aerial.nvim": { "branch": "master", "commit": "ddd25f57e5205b36bc2e939c486b47818bef9ec3" }, "catppuccin": { "branch": "main", "commit": "637d99e638bc6f1efedac582f6ccab08badac0c6" }, "ccc.nvim": { "branch": "main", "commit": "4fb5abaef2f2e0540fe22d4d74a9841205fff9e4" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, @@ -10,7 +10,6 @@ "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, - "codecompanion.nvim": { "branch": "main", "commit": "ade8d29c94f6ad3c5b4ccf38517cec13126a6f0d" }, "comment-box.nvim": { "branch": "main", "commit": "06bb771690bc9df0763d14769b779062d8f12bc5" }, "conform.nvim": { "branch": "master", "commit": "0ebe875d9c306f5fc829db38492ffff2a70d8e9d" }, "copilot-cmp": { "branch": "master", "commit": "b6e5286b3d74b04256d0a7e3bd2908eabec34b44" }, diff --git a/config/nvim/lua/aleidk/plugins-core/markdown.lua b/config/nvim/lua/aleidk/plugins-core/markdown.lua index 3fc9cbb..19e36a2 100644 --- a/config/nvim/lua/aleidk/plugins-core/markdown.lua +++ b/config/nvim/lua/aleidk/plugins-core/markdown.lua @@ -6,7 +6,7 @@ return { -- dependencies = { 'nvim-treesitter/nvim-treesitter', 'echasnovski/mini.icons' }, -- if you use standalone mini plugins dependencies = { "nvim-treesitter/nvim-treesitter", "nvim-tree/nvim-web-devicons" }, -- if you prefer nvim-web-devicons opts = { - file_types = { 'markdown', 'codecompanion' }, + file_types = { 'markdown', 'copilot-chat' }, sign = { enabled = false, }, diff --git a/config/nvim/lua/aleidk/plugins-ide/ai.lua b/config/nvim/lua/aleidk/plugins-ide/ai.lua index 28abb89..f6e9df7 100644 --- a/config/nvim/lua/aleidk/plugins-ide/ai.lua +++ b/config/nvim/lua/aleidk/plugins-ide/ai.lua @@ -1,8 +1,10 @@ return { - "olimorris/codecompanion.nvim", + "CopilotC-Nvim/CopilotChat.nvim", + branch = "canary", + build = "make tiktoken", + cmd = "CopilotChat", dependencies = { "nvim-lua/plenary.nvim", - "nvim-treesitter/nvim-treesitter", { "zbirenbaum/copilot.lua", cmd = "Copilot", @@ -14,71 +16,93 @@ return { }) end, }, - "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 `vim.ui.select` }, - opts = { - strategies = { - chat = { - adapter = "copilot", - }, - inline = { - adapter = "copilot", - }, - agent = { adapter = "copilot" }, - }, - display = { - action_palette = { - prompt = " " - }, - chat = { - window = { - layout = "float", - height = 0.8, - width = 0.8, + opts = function() + local user = vim.env.USER or "User" + user = user:sub(1, 1):upper() .. user:sub(2) + + return { + prompts = { + Explain = { + prompt = '> /COPILOT_EXPLAIN\n\nWrite an explanation for the selected code as paragraphs of text.', }, - } + Review = { + prompt = '> /COPILOT_REVIEW\n\nReview the selected code.', + -- see config.lua for implementation + }, + Fix = { + prompt = + '> /COPILOT_GENERATE\n\nThere is a problem in this code. Rewrite the code to show it with the bug fixed.', + }, + Optimize = { + prompt = '> /COPILOT_GENERATE\n\nOptimize the selected code to improve performance and readability.', + }, + Docs = { + prompt = '> /COPILOT_GENERATE\n\nPlease add documentation comments to the selected code.', + }, + Tests = { + prompt = '> /COPILOT_GENERATE\n\nPlease generate tests for my code.', + }, + Commit = { + prompt = + '> #git:staged\n\nWrite commit message for the change with commitizen convention. Make sure the title has maximum 50 characters and message is wrapped at 72 characters. Wrap the whole message in code block with language gitcommit.', + }, + }, + question_header = " " .. user .. " ", + answer_header = " Copilot ", + window = { + layout = 'float', -- 'vertical', 'horizontal', 'float', 'replace' + width = 0.8, -- fractional width of parent, or absolute width in columns when > 1 + height = 0.8, -- fractional height of parent, or absolute height in rows when > 1 + -- Options below only apply to floating windows + relative = 'editor', -- 'editor', 'win', 'cursor', 'mouse' + border = 'rounded', -- 'none', single', 'double', 'rounded', 'solid', 'shadow' + title = ' ', -- title of chat window + zindex = 1, -- determines if window is on top or below other floating windows + }, } - }, + end, keys = { { "at", function() - require("codecompanion").toggle() + require("CopilotChat").toggle() end, - desc = "Toggle AI chat", - mode = { "n", "v" } + desc = "Toggle window", + mode = { "n", "v" }, }, { "aa", - "CodeCompanion", - desc = "Run an inline prompt", - mode = { "n", "v" } + function() + local input = vim.fn.input("Quick Chat: ") + if input ~= "" then + require("CopilotChat").ask(input) + end + end, + desc = "Quick chat", + mode = { "n", "v" }, }, { "aA", function() - require("codecompanion").actions() + -- Pick a prompt using vim.ui.select + local actions = require("CopilotChat.actions") + + -- Pick prompt actions + actions.pick(actions.prompt_actions({ + selection = require("CopilotChat.select").visual, + })) end, - desc = "Open AI actions", - mode = { "n", "v" } + desc = "Select action", + mode = { "n", "v" }, }, { - "av", + "ax", function() - require("codecompanion").add() + return require("CopilotChat").reset() end, - desc = "Add visual selection to chat", - mode = "v" - }, - { - "ae", - function() - require("codecompanion").prompt("explain") - end, - desc = "Explain code", - mode = "v" + desc = "Clear chat", + mode = { "n", "v" }, }, } }