108 lines
3 KiB
Lua
108 lines
3 KiB
Lua
return {
|
|
"CopilotC-Nvim/CopilotChat.nvim",
|
|
branch = "canary",
|
|
build = "make tiktoken",
|
|
cmd = "CopilotChat",
|
|
dependencies = {
|
|
"nvim-lua/plenary.nvim",
|
|
{
|
|
"zbirenbaum/copilot.lua",
|
|
cmd = "Copilot",
|
|
event = "InsertEnter",
|
|
config = function()
|
|
require("copilot").setup({
|
|
suggestion = { enabled = false },
|
|
panel = { enabled = true, auto_refresh = true },
|
|
})
|
|
end,
|
|
},
|
|
},
|
|
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 = {
|
|
{
|
|
"<leader>at",
|
|
function()
|
|
require("CopilotChat").toggle()
|
|
end,
|
|
desc = "Toggle window",
|
|
mode = { "n", "v" },
|
|
},
|
|
{
|
|
"<leader>aa",
|
|
function()
|
|
local input = vim.fn.input("Quick Chat: ")
|
|
if input ~= "" then
|
|
require("CopilotChat").ask(input)
|
|
end
|
|
end,
|
|
desc = "Quick chat",
|
|
mode = { "n", "v" },
|
|
},
|
|
{
|
|
"<leader>aA",
|
|
function()
|
|
-- 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 = "Select action",
|
|
mode = { "n", "v" },
|
|
},
|
|
{
|
|
"<leader>ax",
|
|
function()
|
|
return require("CopilotChat").reset()
|
|
end,
|
|
desc = "Clear chat",
|
|
mode = { "n", "v" },
|
|
},
|
|
}
|
|
}
|