branch="main",-- Ensure we're using the stable main branch
dependencies={
-- Dependencies for CopilotChat
{"github/copilot.vim"},-- The base Copilot plugin
{"nvim-lua/plenary.nvim"},-- Common Lua functions
{"nvim-telescope/telescope.nvim"},-- For nice UI integration
{"nvim-tree/nvim-web-devicons"},-- Icons for enhanced UI
},
-- Load after GitHub Copilot and when a file is opened
event={"VeryLazy"},
config=function()
localchat=require("CopilotChat")
localselect=require("CopilotChat.select")
-- Configure the plugin with advanced settings
chat.setup({
-- Show Copilot Chat window border
window={
border="rounded",-- Make the window look nice
width=80,-- Default width
height=20,-- Default height
title={
name="Copilot Chat",-- Custom title
alignment="center",-- Center the title
},
},
-- File context features
context={
-- Include 5 lines above and below the cursor for context
cursor_context=5,
-- Include the entire selection when using visual mode
selection_context=true,
-- Show context-aware commit history
git_context=true,
},
-- Enable debug (set to true only when troubleshooting)
debug=false,
-- Enable syntax highlighting in response
syntax_highlighting=true,
-- Enable auto-sizing of response window
auto_size=true,
-- Define prompts that can be used in commands
prompts={
-- Default prompts
Explain={
prompt="Explain how the following code works in detail:\n```$filetype\n$selection\n```",
},
FixCode={
prompt="Fix the following code. Provide the corrected version and explanations for the fixes:\n```$filetype\n$selection\n```",
},
Optimize={
prompt="Optimize the following code. Provide the optimized version and explain the improvements:\n```$filetype\n$selection\n```",
},
-- Advanced prompts
Documentation={
prompt="Generate comprehensive documentation for this code:\n```$filetype\n$selection\n```\nInclude descriptions of parameters, return values, exceptions, and provide usage examples.",
},
BestPractices={
prompt="Review this code for best practices and suggest improvements:\n```$filetype\n$selection\n```",
},
Tests={
prompt="Generate unit tests for the following code:\n```$filetype\n$selection\n```",
},
-- Context-aware code generation
Implement={
prompt="Implement the following functionality: $input\nMake it work with the following context:\n```$filetype\n$selection\n```",
strategy="quick_fix",-- Use the quick fix strategy for implementation
},
RefactorToPattern={
prompt="Refactor the following code to use the $input design pattern. Explain the benefits of this refactoring:\n```$filetype\n$selection\n```",