|
1 | 1 | # copilot.lua
|
2 | 2 |
|
3 | 3 | This plugin is the pure lua replacement for [github/copilot.vim](https://github.com/github/copilot.vim).
|
| 4 | +A huge thank you to @tris203 for the code behind the nes functionality ([copilot-lsp](https://github.com/copilotlsp-nvim/copilot-lsp)). |
4 | 5 |
|
5 | 6 | <details>
|
6 | 7 | <summary>Motivation behind `copilot.lua`</summary>
|
@@ -48,7 +49,11 @@ Install the plugin with your preferred plugin manager.
|
48 | 49 | For example, with [packer.nvim](https://github.com/wbthomason/packer.nvim):
|
49 | 50 |
|
50 | 51 | ```lua
|
51 |
| -use { "zbirenbaum/copilot.lua" } |
| 52 | +use { "zbirenbaum/copilot.lua" |
| 53 | + requires = { |
| 54 | + "copilotlsp-nvim/copilot-lsp", -- (optional) for NES functionality |
| 55 | + }, |
| 56 | +} |
52 | 57 | ```
|
53 | 58 |
|
54 | 59 | ### Authentication
|
@@ -93,6 +98,9 @@ For example:
|
93 | 98 | ```lua
|
94 | 99 | use {
|
95 | 100 | "zbirenbaum/copilot.lua",
|
| 101 | + requires = { |
| 102 | + "copilotlsp-nvim/copilot-lsp", -- (optional) for NES functionality |
| 103 | + }, |
96 | 104 | cmd = "Copilot",
|
97 | 105 | event = "InsertEnter",
|
98 | 106 | config = function()
|
@@ -136,16 +144,14 @@ require('copilot').setup({
|
136 | 144 | dismiss = "<C-]>",
|
137 | 145 | },
|
138 | 146 | },
|
139 |
| - filetypes = { |
140 |
| - yaml = false, |
141 |
| - markdown = false, |
142 |
| - help = false, |
143 |
| - gitcommit = false, |
144 |
| - gitrebase = false, |
145 |
| - hgcommit = false, |
146 |
| - svn = false, |
147 |
| - cvs = false, |
148 |
| - ["."] = false, |
| 147 | + nes = { |
| 148 | + enabled = false, -- requires copilot-lsp as a dependency |
| 149 | + auto_trigger = false, |
| 150 | + keymap = { |
| 151 | + accept_and_goto = false, |
| 152 | + accept = false, |
| 153 | + dismiss = false, |
| 154 | + }, |
149 | 155 | },
|
150 | 156 | auth_provider_url = nil, -- URL to authentication provider, if not "https://github.com/"
|
151 | 157 | logger = {
|
@@ -270,6 +276,43 @@ require("copilot.suggestion").toggle_auto_trigger()
|
270 | 276 | ```
|
271 | 277 | These can also be accessed through the `:Copilot suggestion <function>` command (eg. `:Copilot suggestion accept`).
|
272 | 278 |
|
| 279 | +### nes (next edit suggestion) |
| 280 | + |
| 281 | +>[!WARNING] |
| 282 | +> This feature is still experimental and may not work as expected in all scenarios, please report any issues you encounter. |
| 283 | +
|
| 284 | +When `enabled` is `true`, copilot will provide suggestions based on the next edit you are likely to make, through [copilot-lsp](https://github.com/copilotlsp-nvim/copilot-lsp). |
| 285 | +If there is no suggestion, the keymaps will pass through the original keymap. |
| 286 | + |
| 287 | +`copilot-lsp` has a few configurations built-in as well, for additional configurations, please refer to the [copilot-lsp documentation](https://github.com/copilotlsp-nvim/copilot-lsp/blob/main/README.md). |
| 288 | +These configurations should be set in the `init` function of the `copilot-lsp` dependency. |
| 289 | + |
| 290 | +```lua |
| 291 | +use { |
| 292 | + "zbirenbaum/copilot.lua", |
| 293 | + requires = { |
| 294 | + "copilotlsp-nvim/copilot-lsp", |
| 295 | + init = function() |
| 296 | + vim.g.copilot_nes_debounce = 500 |
| 297 | + end, |
| 298 | + }, |
| 299 | + cmd = "Copilot", |
| 300 | + event = "InsertEnter", |
| 301 | + config = function() |
| 302 | + require("copilot").setup({ |
| 303 | + nes = { |
| 304 | + enabled = true, |
| 305 | + keymap = { |
| 306 | + accept_and_goto = "<leader>p", |
| 307 | + accept = false, |
| 308 | + dismiss = "<Esc>", |
| 309 | + }, |
| 310 | + }, |
| 311 | + }) |
| 312 | + end, |
| 313 | +} |
| 314 | +``` |
| 315 | + |
273 | 316 | ### filetypes
|
274 | 317 |
|
275 | 318 | Specify filetypes for attaching copilot.
|
|
0 commit comments