148 lines
4.8 KiB
Lua
148 lines
4.8 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 = false },
|
|
})
|
|
|
|
vim.g.copilot_autocomplete_enabled = false
|
|
|
|
vim.api.nvim_create_user_command("CopilotToggleAutocomplete", function()
|
|
vim.g.copilot_autocomplete_enabled = not vim.g.copilot_autocomplete_enabled
|
|
print("Copilot autocompletion: " .. tostring(vim.g.copilot_autocomplete_enabled))
|
|
end, { desc = "Toggle Copilot autocompletion" })
|
|
end,
|
|
},
|
|
},
|
|
opts =
|
|
---@type CopilotChat.config
|
|
{
|
|
---@type table<string, CopilotChat.config.prompt>
|
|
prompts = {
|
|
HowDoI = {
|
|
system_prompt = [[
|
|
> /COPILOT_EXPLAIN
|
|
|
|
You are gonna be asked for guidance about how to solve a problem or archeive a goal. For that your answers need to follow these rules:
|
|
|
|
1. Provide brief, consice and unambiguos responses.
|
|
2. You need to response with an step by step list of actions needed to complete the task.
|
|
3. **You never have to give an explicit answer**, instead provide a high level overview of how to complete the task.
|
|
4. Unless explicity asked by the user, **you never have to provide code snippets** in your responses. Only provide code snippets when the user says so in each question.
|
|
5. If the user ask for a code snippet, **prefer to respond in pseudo code**, unless the user explicity asked for a concrete language.
|
|
6. You need to have into consideration good and clean code practices, code performance and other standards, comunicate in your response this considerations and common pitfalls to avoid.
|
|
7. If possible, include how the user can test the task is completed successfully with the title "## Testing".
|
|
8. Use markdawn syntax highlighting when possible.
|
|
9. You are allowed to reference the following elements but without giving examples of usage (unless the user ask for it):
|
|
- Elements from the language syntaxis.
|
|
- Standard library of the lenguage.
|
|
- External libraries and/or frameworks.
|
|
- The idiomatic way of acomplish something in the language.
|
|
- Data structures and algorithms that could help complete the task.
|
|
|
|
If you have multiple aproaches of how the task can be solved, insert the title "## Options", then generate separate list of task, each in the form of "### Option A", "### Option B", etc so he/her can have it into consideration.
|
|
The numbering of each list needs to be independen of each other, also provide only 1 list per aproach.
|
|
|
|
The user can ask follow up question, which needs to follow the same rules.
|
|
]]
|
|
},
|
|
},
|
|
question_header = " " .. vim.env.USER or "User" .. " ",
|
|
answer_header = " Copilot ",
|
|
auto_follow_cursor = false,
|
|
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
|
|
},
|
|
},
|
|
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
|
|
return
|
|
end
|
|
require("CopilotChat").ask(input)
|
|
end,
|
|
desc = "Quick chat",
|
|
mode = { "n", "v" },
|
|
},
|
|
{
|
|
"<leader>ah",
|
|
function()
|
|
local input = vim.fn.input(" How do I...")
|
|
if input == "" then
|
|
return
|
|
end
|
|
|
|
local chat = require("CopilotChat")
|
|
|
|
local promptConfig = chat.prompts()["HowDoI"]
|
|
chat.ask(input, promptConfig)
|
|
end,
|
|
desc = "How do I...",
|
|
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({}), {
|
|
prompt = " Prompts:",
|
|
}
|
|
)
|
|
end,
|
|
desc = "Select action",
|
|
mode = { "n", "v" },
|
|
},
|
|
{
|
|
"<leader>ax",
|
|
function()
|
|
return require("CopilotChat").reset()
|
|
end,
|
|
desc = "Clear chat",
|
|
mode = { "n", "v" },
|
|
},
|
|
{
|
|
"<leader>al",
|
|
function()
|
|
return require("CopilotChat").log_level("debug")
|
|
end,
|
|
desc = "Set debug level",
|
|
},
|
|
{
|
|
"<leader>ad",
|
|
"<CMD>CopilotChatDocs<CR>",
|
|
desc = "Generate documentation",
|
|
mode = { "n", "v" },
|
|
},
|
|
}
|
|
}
|