forked from CopilotC-Nvim/CopilotChat.nvim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCopilotChat.txt
More file actions
291 lines (220 loc) · 9.76 KB
/
Copy pathCopilotChat.txt
File metadata and controls
291 lines (220 loc) · 9.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
*CopilotChat.txt* For NVIM v0.8.0 Last change: 2024 February 02
==============================================================================
Table of Contents *CopilotChat-table-of-contents*
1. Copilot Chat for Neovim |CopilotChat-copilot-chat-for-neovim|
- Authentication |CopilotChat-copilot-chat-for-neovim-authentication|
- Installation |CopilotChat-copilot-chat-for-neovim-installation|
- Usage |CopilotChat-copilot-chat-for-neovim-usage|
- Receipts |CopilotChat-copilot-chat-for-neovim-receipts|
- Roadmap |CopilotChat-copilot-chat-for-neovim-roadmap|
- Contributors ✨ |CopilotChat-copilot-chat-for-neovim-contributors-✨|
==============================================================================
1. Copilot Chat for Neovim *CopilotChat-copilot-chat-for-neovim*
|CopilotChat-|
[!NOTE] A new command, `CopilotChatInPlace` has been introduced. It functions
like the ChatGPT plugin. Please run ":UpdateRemotePlugins" command and restart
Neovim before starting a chat with Copilot. To stay updated on our roadmap,
please join our Discord <https://discord.gg/vy6hJsTWaZ> community.
AUTHENTICATION *CopilotChat-copilot-chat-for-neovim-authentication*
It will prompt you with instructions on your first start. If you already have
`Copilot.vim` or `Copilot.lua`, it will work automatically.
INSTALLATION *CopilotChat-copilot-chat-for-neovim-installation*
LAZY.NVIM ~
1. `pip install python-dotenv requests pynvim==0.5.0 prompt-toolkit`
2. `pip install tiktoken` (optional for displaying prompt token counts)
3. Put it in your lazy setup
>lua
return {
{
"jellydn/CopilotChat.nvim",
dependencies = { "zbirenbaum/copilot.lua" }, -- Or { "github/copilot.vim" }
opts = {
show_help = "yes", -- Show help text for CopilotChatInPlace, default: yes
debug = false, -- Enable or disable debug mode, the log file will be in ~/.local/state/nvim/CopilotChat.nvim.log
},
build = function()
vim.notify("Please update the remote plugins by running ':UpdateRemotePlugins', then restart Neovim.")
end,
event = "VeryLazy",
keys = {
{ "<leader>cce", "<cmd>CopilotChatExplain<cr>", desc = "CopilotChat - Explain code" },
{ "<leader>cct", "<cmd>CopilotChatTests<cr>", desc = "CopilotChat - Generate tests" },
{
"<leader>ccv",
":CopilotChatVisual",
mode = "x",
desc = "CopilotChat - Open in vertical split",
},
{
"<leader>ccx",
":CopilotChatInPlace<cr>",
mode = "x",
desc = "CopilotChat - Run in-place code",
},
},
},
}
<
1. Run `:UpdateRemotePlugins`
2. Restart `neovim`
MANUAL ~
1. Put the files in the right place
>
$ git clone https://github.com/jellydn/CopilotChat.nvim
$ cd CopilotChat.nvim
$ cp -r --backup=nil rplugin ~/.config/nvim/
<
1. Install dependencies
>
$ pip install -r requirements.txt
<
1. Open up Neovim and run `:UpdateRemotePlugins`
2. Restart Neovim
USAGE *CopilotChat-copilot-chat-for-neovim-usage*
CONFIGURATION ~
You have the ability to tailor this plugin to your specific needs using the
configuration options outlined below:
>lua
{
debug = false, -- Enable or disable debug mode
show_help = 'yes', -- Show help text for CopilotChatInPlace
prompts = { -- Set dynamic prompts for CopilotChat commands
Explain = 'Explain how it works.',
Tests = 'Briefly explain how the selected code works, then generate unit tests.',
}
}
<
You have the capability to expand the prompts to create more versatile
commands:
>lua
return {
"jellydn/CopilotChat.nvim",
opts = {
debug = true,
show_help = "yes",
prompts = {
Explain = "Explain how it works.",
Review = "Review the following code and provide concise suggestions.",
Tests = "Briefly explain how the selected code works, then generate unit tests.",
Refactor = "Refactor the code to improve clarity and readability.",
},
},
build = function()
vim.notify("Please update the remote plugins by running ':UpdateRemotePlugins', then restart Neovim.")
end,
event = "VeryLazy",
keys = {
{ "<leader>cce", "<cmd>CopilotChatExplain<cr>", desc = "CopilotChat - Explain code" },
{ "<leader>cct", "<cmd>CopilotChatTests<cr>", desc = "CopilotChat - Generate tests" },
{ "<leader>ccr", "<cmd>CopilotChatReview<cr>", desc = "CopilotChat - Review code" },
{ "<leader>ccR", "<cmd>CopilotChatRefactor<cr>", desc = "CopilotChat - Refactor code" },
}
}
<
For further reference, you can view @jellydn’s configuration
<https://github.com/jellydn/lazy-nvim-ide/blob/main/lua/plugins/extras/copilot-chat.lua>.
CHAT WITH GITHUB COPILOT ~
1. Copy some code into the unnamed register using the `y` command.
2. Run the command `:CopilotChat` followed by your question. For example, `:CopilotChat What does this code do?`
CODE EXPLANATION ~
1. Copy some code into the unnamed register using the `y` command.
2. Run the command `:CopilotChatExplain`.
GENERATE TESTS ~
1. Copy some code into the unnamed register using the `y` command.
2. Run the command `:CopilotChatTests`.
<https://gyazo.com/f285467d4b8d8f8fd36aa777305312ae>
TOKEN COUNT & FOLD WITH VISUAL MODE ~
1. Select some code using visual mode.
2. Run the command `:CopilotChatVisual` with your question.
<https://gyazo.com/766fb3b6ffeb697e650fc839882822a8>
IN-PLACE CHAT POPUP ~
1. Select some code using visual mode.
2. Run the command `:CopilotChatInPlace` and type your prompt. For example, `What does this code do?`
3. Press `Enter` to send your question to Github Copilot.
4. Press `q` to quit. There is help text at the bottom of the screen. You can also press `?` to toggle the help text.
<https://gyazo.com/4a5badaa109cd483c1fc23d296325cb0>
RECEIPTS *CopilotChat-copilot-chat-for-neovim-receipts*
HOW TO SETUP WITH WHICH-KEY.NVIM ~
A special thanks to @ecosse3 for the configuration of which-key
<https://github.com/jellydn/CopilotChat.nvim/issues/30>.
>lua
{
"jellydn/CopilotChat.nvim",
event = "VeryLazy",
opts = {
prompts = {
Explain = "Explain how it works.",
Review = "Review the following code and provide concise suggestions.",
Tests = "Briefly explain how the selected code works, then generate unit tests.",
Refactor = "Refactor the code to improve clarity and readability.",
},
},
build = function()
vim.notify("Please update the remote plugins by running ':UpdateRemotePlugins', then restart Neovim.")
end,
config = function()
local present, wk = pcall(require, "which-key")
if not present then
return
end
wk.register({
c = {
c = {
name = "Copilot Chat",
}
}
}, {
mode = "n",
prefix = "<leader>",
silent = true,
noremap = true,
nowait = false,
})
end,
keys = {
{ "<leader>ccc", ":CopilotChat ", desc = "CopilotChat - Prompt" },
{ "<leader>cce", ":CopilotChatExplain ", desc = "CopilotChat - Explain code" },
{ "<leader>cct", "<cmd>CopilotChatTests<cr>", desc = "CopilotChat - Generate tests" },
{ "<leader>ccr", "<cmd>CopilotChatReview<cr>", desc = "CopilotChat - Review code" },
{ "<leader>ccR", "<cmd>CopilotChatRefactor<cr>", desc = "CopilotChat - Refactor code" },
}
},
<
CREATE A SIMPLE INPUT FOR COPILOTCHAT ~
Follow the example below to create a simple input for CopilotChat.
>lua
-- Create input for CopilotChat
{
"<leader>cci",
function()
local input = vim.fn.input("Ask Copilot: ")
if input ~= "" then
vim.cmd("CopilotChat " .. input)
end
end,
desc = "CopilotChat - Ask input",
},
<
ROADMAP *CopilotChat-copilot-chat-for-neovim-roadmap*
- Translation to pure Lua
- Tokenizer
- Use vector encodings to automatically select code
- Sub commands - See issue #5 <https://github.com/gptlang/CopilotChat.nvim/issues/5>
CONTRIBUTORS ✨ *CopilotChat-copilot-chat-for-neovim-contributors-✨*
Thanks goes to these wonderful people (emoji key
<https://allcontributors.org/docs/en/emoji-key>):
gptlang💻 📖Dung Duc Huynh (Kaka)💻 📖Ahmed Haracic💻Trí Thiện Nguyễn💻He Zhizhou💻Guruprakash Rajakkannu💻This project follows the all-contributors
<https://github.com/all-contributors/all-contributors> specification.
Contributions of any kind welcome!
==============================================================================
2. Links *CopilotChat-links*
1. *All Contributors*: https://img.shields.io/badge/all_contributors-6-orange.svg?style=flat-square
2. *@jellydn*:
3. *Chat Demo*: https://i.gyazo.com/10fbd1543380d15551791c1a6dcbcd46.gif
4. *Explain Code Demo*: https://i.gyazo.com/e5031f402536a1a9d6c82b2c38d469e3.gif
5. *Generate tests*: https://i.gyazo.com/f285467d4b8d8f8fd36aa777305312ae.gif
6. *Fold Demo*: https://i.gyazo.com/766fb3b6ffeb697e650fc839882822a8.gif
7. *In-place Demo*: https://i.gyazo.com/4a5badaa109cd483c1fc23d296325cb0.gif
8. *@ecosse3*:
Generated by panvimdoc <https://github.com/kdheepak/panvimdoc>
vim:tw=78:ts=8:noet:ft=help:norl: