Files

133 lines
3.5 KiB
Lua

return {
{
"CopilotC-Nvim/CopilotChat.nvim",
branch = "main",
dependencies = {
{ "github/copilot.vim" },
{ "nvim-lua/plenary.nvim" },
},
build = "make tiktoken",
opts = function()
local copilot_select = require("CopilotChat.select") -- Importiere hier
return {
debug = true,
system_prompt = "You are an AI coding assistant called Copilot.",
model = "gpt-4o",
temperature = 0.1,
question_header = "## User ",
answer_header = "## Copilot ",
error_header = "## Error ",
separator = "───",
show_folds = true,
show_help = true,
auto_follow_cursor = true,
auto_insert_mode = false,
insert_at_end = false,
clear_chat_on_new_prompt = false,
highlight_selection = true,
context = nil,
history_path = vim.fn.stdpath("data") .. "/copilotchat_history",
callback = nil,
-- Default selection (visual or line)
selection = function(source)
return copilot_select.visual(source) or copilot_select.line(source)
end,
-- Default prompts
prompts = {
Explain = {
prompt = "/COPILOT_EXPLAIN Write an explanation for the active selection as paragraphs of text.",
},
Review = {
prompt = "/COPILOT_REVIEW Review the selected code.",
callback = function(response, source)
-- siehe config.lua für die Implementierung
end,
},
Fix = {
prompt = "/COPILOT_GENERATE There is a problem in this code. Rewrite the code to show it with the bug fixed.",
},
Optimize = {
prompt = "/COPILOT_GENERATE Optimize the selected code to improve performance and readability.",
},
Docs = {
prompt = "/COPILOT_GENERATE Please add documentation comment for the selection.",
},
Tests = {
prompt = "/COPILOT_GENERATE Please generate tests for my code.",
},
FixDiagnostic = {
prompt = "Please assist with the following diagnostic issue in file:",
selection = copilot_select.diagnostics,
},
Commit = {
prompt =
"Write 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.",
selection = copilot_select.gitdiff,
},
CommitStaged = {
prompt =
"Write 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.",
selection = function(source)
return copilot_select.gitdiff(source, true)
end,
},
},
-- Default window options
window = {
layout = "vertical",
width = 0.5,
height = 0.5,
relative = "editor",
border = "single",
title = "Copilot Chat",
zindex = 1,
},
-- Default mappings
mappings = {
complete = {
detail = "Use @<Tab> or /<Tab> for options.",
insert = "<Tab>",
},
close = {
normal = "q",
insert = "<C-c>",
},
reset = {
normal = "<C-l>",
insert = "<C-l>",
},
submit_prompt = {
normal = "<CR>",
insert = "<C-s>",
},
accept_diff = {
normal = "<C-y>",
insert = "<C-y>",
},
yank_diff = {
normal = "gy",
register = '"',
},
show_diff = {
normal = "gd",
},
show_system_prompt = {
normal = "gp",
},
show_user_selection = {
normal = "gs",
},
},
}
end,
},
}