change ai plugin to CopilotChat.nvim
This commit is contained in:
parent
1366b1d7b0
commit
ec750a0e89
3 changed files with 73 additions and 50 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
|
"CopilotChat.nvim": { "branch": "canary", "commit": "df19e7ab15537436a26f59fa991f2fa81d847a0d" },
|
||||||
"LuaSnip": { "branch": "master", "commit": "ce0a05ab4e2839e1c48d072c5236cce846a387bc" },
|
"LuaSnip": { "branch": "master", "commit": "ce0a05ab4e2839e1c48d072c5236cce846a387bc" },
|
||||||
"aerial.nvim": { "branch": "master", "commit": "ddd25f57e5205b36bc2e939c486b47818bef9ec3" },
|
|
||||||
"catppuccin": { "branch": "main", "commit": "637d99e638bc6f1efedac582f6ccab08badac0c6" },
|
"catppuccin": { "branch": "main", "commit": "637d99e638bc6f1efedac582f6ccab08badac0c6" },
|
||||||
"ccc.nvim": { "branch": "main", "commit": "4fb5abaef2f2e0540fe22d4d74a9841205fff9e4" },
|
"ccc.nvim": { "branch": "main", "commit": "4fb5abaef2f2e0540fe22d4d74a9841205fff9e4" },
|
||||||
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
|
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
|
||||||
|
|
@ -10,7 +10,6 @@
|
||||||
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
|
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
|
||||||
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
|
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
|
||||||
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
|
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
|
||||||
"codecompanion.nvim": { "branch": "main", "commit": "ade8d29c94f6ad3c5b4ccf38517cec13126a6f0d" },
|
|
||||||
"comment-box.nvim": { "branch": "main", "commit": "06bb771690bc9df0763d14769b779062d8f12bc5" },
|
"comment-box.nvim": { "branch": "main", "commit": "06bb771690bc9df0763d14769b779062d8f12bc5" },
|
||||||
"conform.nvim": { "branch": "master", "commit": "0ebe875d9c306f5fc829db38492ffff2a70d8e9d" },
|
"conform.nvim": { "branch": "master", "commit": "0ebe875d9c306f5fc829db38492ffff2a70d8e9d" },
|
||||||
"copilot-cmp": { "branch": "master", "commit": "b6e5286b3d74b04256d0a7e3bd2908eabec34b44" },
|
"copilot-cmp": { "branch": "master", "commit": "b6e5286b3d74b04256d0a7e3bd2908eabec34b44" },
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ return {
|
||||||
-- dependencies = { 'nvim-treesitter/nvim-treesitter', 'echasnovski/mini.icons' }, -- if you use standalone mini plugins
|
-- 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
|
dependencies = { "nvim-treesitter/nvim-treesitter", "nvim-tree/nvim-web-devicons" }, -- if you prefer nvim-web-devicons
|
||||||
opts = {
|
opts = {
|
||||||
file_types = { 'markdown', 'codecompanion' },
|
file_types = { 'markdown', 'copilot-chat' },
|
||||||
sign = {
|
sign = {
|
||||||
enabled = false,
|
enabled = false,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
return {
|
return {
|
||||||
"olimorris/codecompanion.nvim",
|
"CopilotC-Nvim/CopilotChat.nvim",
|
||||||
|
branch = "canary",
|
||||||
|
build = "make tiktoken",
|
||||||
|
cmd = "CopilotChat",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"nvim-lua/plenary.nvim",
|
"nvim-lua/plenary.nvim",
|
||||||
"nvim-treesitter/nvim-treesitter",
|
|
||||||
{
|
{
|
||||||
"zbirenbaum/copilot.lua",
|
"zbirenbaum/copilot.lua",
|
||||||
cmd = "Copilot",
|
cmd = "Copilot",
|
||||||
|
|
@ -14,71 +16,93 @@ return {
|
||||||
})
|
})
|
||||||
end,
|
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 = {
|
opts = function()
|
||||||
strategies = {
|
local user = vim.env.USER or "User"
|
||||||
chat = {
|
user = user:sub(1, 1):upper() .. user:sub(2)
|
||||||
adapter = "copilot",
|
|
||||||
},
|
return {
|
||||||
inline = {
|
prompts = {
|
||||||
adapter = "copilot",
|
Explain = {
|
||||||
},
|
prompt = '> /COPILOT_EXPLAIN\n\nWrite an explanation for the selected code as paragraphs of text.',
|
||||||
agent = { adapter = "copilot" },
|
|
||||||
},
|
|
||||||
display = {
|
|
||||||
action_palette = {
|
|
||||||
prompt = " "
|
|
||||||
},
|
|
||||||
chat = {
|
|
||||||
window = {
|
|
||||||
layout = "float",
|
|
||||||
height = 0.8,
|
|
||||||
width = 0.8,
|
|
||||||
},
|
},
|
||||||
}
|
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 = {
|
keys = {
|
||||||
{
|
{
|
||||||
"<leader>at",
|
"<leader>at",
|
||||||
function()
|
function()
|
||||||
require("codecompanion").toggle()
|
require("CopilotChat").toggle()
|
||||||
end,
|
end,
|
||||||
desc = "Toggle AI chat",
|
desc = "Toggle window",
|
||||||
mode = { "n", "v" }
|
mode = { "n", "v" },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"<leader>aa",
|
"<leader>aa",
|
||||||
"<CMD>CodeCompanion<CR>",
|
function()
|
||||||
desc = "Run an inline prompt",
|
local input = vim.fn.input("Quick Chat: ")
|
||||||
mode = { "n", "v" }
|
if input ~= "" then
|
||||||
|
require("CopilotChat").ask(input)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
desc = "Quick chat",
|
||||||
|
mode = { "n", "v" },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"<leader>aA",
|
"<leader>aA",
|
||||||
function()
|
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,
|
end,
|
||||||
desc = "Open AI actions",
|
desc = "Select action",
|
||||||
mode = { "n", "v" }
|
mode = { "n", "v" },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"<leader>av",
|
"<leader>ax",
|
||||||
function()
|
function()
|
||||||
require("codecompanion").add()
|
return require("CopilotChat").reset()
|
||||||
end,
|
end,
|
||||||
desc = "Add visual selection to chat",
|
desc = "Clear chat",
|
||||||
mode = "v"
|
mode = { "n", "v" },
|
||||||
},
|
|
||||||
{
|
|
||||||
"<leader>ae",
|
|
||||||
function()
|
|
||||||
require("codecompanion").prompt("explain")
|
|
||||||
end,
|
|
||||||
desc = "Explain code",
|
|
||||||
mode = "v"
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue