Skip to content

Commit cddd5e8

Browse files
committed
docs: add configuration section
1 parent f0beab7 commit cddd5e8

2 files changed

Lines changed: 45 additions & 7 deletions

File tree

README.md

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,51 @@ $ pip install -r requirements.txt
5757

5858
## Usage
5959

60-
### Chat
60+
### Configuration
6161

62-
To chat with Copilot, follow these steps:
62+
You can customize the CopilotChat plugin using the following configuration options:
63+
64+
```lua
65+
{
66+
debug = false, -- Enable or disable debug mode
67+
prompts = { -- Set dynamic prompts for CopilotChat commands
68+
Explain = 'Explain how it works.',
69+
Tests = 'Briefly explain how the selected code works, then generate unit tests.',
70+
}
71+
}
72+
```
73+
74+
You can extend the prompts to generate more flexible commands:
75+
76+
```lua
77+
return {
78+
"jellydn/CopilotChat.nvim",
79+
opts = {
80+
mode = "split",
81+
prompts = {
82+
Explain = "Explain how it works.",
83+
Review = "Review the following code and provide concise suggestions.",
84+
Tests = "Briefly explain how the selected code works, then generate unit tests.",
85+
Refactor = "Refactor the code to improve clarity and readability.",
86+
},
87+
},
88+
build = function()
89+
vim.defer_fn(function()
90+
vim.cmd("UpdateRemotePlugins")
91+
vim.notify("CopilotChat - Updated remote plugins. Please restart Neovim.")
92+
end, 3000)
93+
end,
94+
event = "VeryLazy",
95+
keys = {
96+
{ "<leader>cce", "<cmd>CopilotChatExplain<cr>", desc = "CopilotChat - Explain code" },
97+
{ "<leader>cct", "<cmd>CopilotChatTests<cr>", desc = "CopilotChat - Generate tests" },
98+
{ "<leader>ccr", "<cmd>CopilotChatReview<cr>", desc = "CopilotChat - Review code" },
99+
{ "<leader>ccR", "<cmd>CopilotChatRefactor<cr>", desc = "CopilotChat - Refactor code" },
100+
}
101+
}
102+
```
103+
104+
### Chat with Github Copilot
63105

64106
1. Copy some code into the unnamed register using the `y` command.
65107
2. Run the command `:CopilotChat` followed by your question. For example, `:CopilotChat What does this code do?`
@@ -68,17 +110,13 @@ To chat with Copilot, follow these steps:
68110

69111
### Code Explanation
70112

71-
To get an explanation of your code, follow these steps:
72-
73113
1. Copy some code into the unnamed register using the `y` command.
74114
2. Run the command `:CopilotChatExplain`.
75115

76116
![Explain Code Demo](https://i.gyazo.com/e5031f402536a1a9d6c82b2c38d469e3.gif)
77117

78118
### Generate Tests
79119

80-
To generate tests for your code, follow these steps:
81-
82120
1. Copy some code into the unnamed register using the `y` command.
83121
2. Run the command `:CopilotChatTests`.
84122

lua/CopilotChat/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ local M = {}
44

55
local default_prompts = {
66
Explain = 'Explain how it works.',
7-
Tests = 'Briefly how selected code works then generate unit tests for the code.',
7+
Tests = 'Briefly how selected code works then generate unit tests.',
88
}
99

1010
-- Set up the plugin

0 commit comments

Comments
 (0)