You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: improve README with better examples and cleaner structure
Previously, the documentation for custom prompts, system prompts and
contexts was scattered and duplicated across multiple sections. This
change consolidates and improves the documentation by:
- Moving examples next to their relevant sections
- Adding clearer and more concise examples for custom prompts, system
prompts and contexts
- Removing duplicate content that was spread across multiple sections
- Making github/copilot.vim the primary recommended Copilot backend
Signed-off-by: Tomas Slusny <[email protected]>
-`Commit` - Write commit message for the change with commitizen convention
123
123
124
+
You can define custom prompts like this (only `prompt` is required):
125
+
126
+
```lua
127
+
{
128
+
prompts= {
129
+
MyCustomPrompt= {
130
+
prompt='Explain how it works.',
131
+
system_prompt='You are very good at explaining stuff',
132
+
mapping='<leader>ccmc',
133
+
description='My custom prompt description',
134
+
}
135
+
}
136
+
}
137
+
```
138
+
124
139
### System Prompts
125
140
126
141
System prompts specify the behavior of the AI model. You can reference system prompts with `/PROMPT_NAME` in chat.
@@ -131,6 +146,18 @@ Default system prompts are:
131
146
-`COPILOT_REVIEW` - On top of the base instructions adds code review behavior with instructions on how to generate diagnostics
132
147
-`COPILOT_GENERATE` - On top of the base instructions adds code generation behavior, with predefined formatting and generation rules
133
148
149
+
You can define custom system prompts like this (works same as `prompts` so you can combine prompt and system prompt definitions):
150
+
151
+
```lua
152
+
{
153
+
prompts= {
154
+
Yarrr= {
155
+
system_prompt='You are fascinated by pirates, so please respond in pirate speak.',
156
+
}
157
+
}
158
+
}
159
+
```
160
+
134
161
### Sticky Prompts
135
162
136
163
You can set sticky prompt in chat by prefixing the text with `> ` using markdown blockquote syntax.
@@ -186,6 +213,39 @@ Default contexts are:
186
213
-`files` - Includes all non-hidden filenames in the current workspace in chat context. Supports input.
187
214
-`git` - Includes current git diff in chat context (default unstaged). Supports input.
188
215
216
+
You can define custom contexts like this:
217
+
218
+
```lua
219
+
{
220
+
contexts= {
221
+
birthday= {
222
+
input=function(callback)
223
+
vim.ui.select({ 'user', 'napoleon' }, {
224
+
prompt='Select birthday> ',
225
+
}, callback)
226
+
end,
227
+
resolve=function(input)
228
+
input=inputor'user'
229
+
localbirthday=input
230
+
ifinput=='user' then
231
+
birthday=birthday..' birthday is April 1, 1990'
232
+
elseifinput=='napoleon' then
233
+
birthday=birthday..' birthday is August 15, 1769'
234
+
end
235
+
236
+
return {
237
+
{
238
+
content=birthday,
239
+
filename=input..'_birthday',
240
+
filetype='text',
241
+
}
242
+
}
243
+
end
244
+
}
245
+
}
246
+
}
247
+
```
248
+
189
249
### API
190
250
191
251
```lua
@@ -396,66 +456,6 @@ Also see [here](/lua/CopilotChat/config.lua):
396
456
}
397
457
```
398
458
399
-
For further reference, you can view @jellydn's [configuration](https://github.com/jellydn/lazy-nvim-ide/blob/main/lua/plugins/extras/copilot-chat-v2.lua).
400
-
401
-
### Defining a prompt with command and keymap
402
-
403
-
This will define prompt that you can reference with `/MyCustomPrompt` in chat, call with `:CopilotChatMyCustomPrompt` or use the keymap `<leader>ccmc`.
404
-
It will use visual selection as default selection. If you are using `lazy.nvim` and are already lazy loading based on `Commands` make sure to include the prompt
405
-
commands and keymaps in `cmd` and `keys` respectively.
406
-
407
-
```lua
408
-
{
409
-
prompts= {
410
-
MyCustomPrompt= {
411
-
prompt='Explain how it works.',
412
-
mapping='<leader>ccmc',
413
-
description='My custom prompt description',
414
-
selection=require('CopilotChat.select').visual,
415
-
},
416
-
},
417
-
}
418
-
```
419
-
420
-
### Referencing system or user prompts
421
-
422
-
You can reference system or user prompts in your configuration or in chat with `/PROMPT_NAME` slash notation.
423
-
For collection of default `COPILOT_` (system) and `USER_` (user) prompts, see [here](/lua/CopilotChat/prompts.lua).
424
-
425
-
```lua
426
-
{
427
-
prompts= {
428
-
MyCustomPrompt= {
429
-
prompt='/COPILOT_EXPLAIN Explain how it works.',
430
-
},
431
-
MyCustomPrompt2= {
432
-
prompt='/MyCustomPrompt Include some additional context.',
433
-
},
434
-
},
435
-
}
436
-
```
437
-
438
-
### Custom system prompts
439
-
440
-
You can define custom system prompts by using `system_prompt` property when passing config around.
441
-
442
-
```lua
443
-
{
444
-
system_prompt='Your name is Github Copilot and you are a AI assistant for developers.',
445
-
prompts= {
446
-
Johnny= {
447
-
system_prompt='Your name is Johny Microsoft and you are not an AI assistant for developers.',
448
-
prompt='Explain how it works.',
449
-
},
450
-
Yarrr= {
451
-
system_prompt='You are fascinated by pirates, so please respond in pirate speak.'
452
-
},
453
-
},
454
-
}
455
-
```
456
-
457
-
To use any of your custom prompts, simply do `:CopilotChat<prompt name>`. E.g. `:CopilotChatJohnny` or `:CopilotChatYarrr What is a sorting algo?`. Tab autocomplete will help you out.
458
-
459
459
### Customizing buffers
460
460
461
461
You can set local options for the buffers that are created by this plugin: `copilot-diff`, `copilot-system-prompt`, `copilot-user-selection`, `copilot-chat`.
0 commit comments