!!! This plugin is deprecated in favor of new features in copilot.lua (auto_trigger = false
) !!!
Client for copilot.lua that utilizes GitHub Copilot as a tool, not a co-pilot.
GitHub Copilot is great, but it can be obtrusive. After using it for almost a year, I can predict when it's going to give me a great suggestion, and when not. It can be very annoying how it tries to give suggestions after almost every keystroke even though all of them are wrong. That's why I came up with this plugin. GitHub Copilot will give you suggestions only when you tell it to. In the demo above you can see the ghost text after pressing Ctrl+c
and waiting for the result.
NOTE: The only other way of using Copilot as a cmp source didn't work well for me either. Cmp panel was too cluttered and having to scroll through suggestions slowed me down in my workflow.
This plugin doesn't start the Copilot server on it's own (hence the name copilot-client). Follow instructions and install copilot.lua in order to have Copilot start as a Language Server. (Verify with :LspInfo
)
Neovim 0.7+ required
With packer
use {
'samodostal/copilot-client.lua',
requires = {
'zbirenbaum/copilot.lua', -- requires copilot.lua and plenary.nvim
'nvim-lua/plenary.nvim'
},
},
With vim.plug
Plug 'samodostal/copilot-client.lua'
Plug 'zbirenbaum/copilot.lua', -- requires copilot.lua and plenary.nvim
Plug 'nvim-lua/plenary.nvim'
-- Require and call setup functions somewhere in your init.lua
require('copilot').setup {
cmp = {
enabled = false, -- no need for cmp
},
}
require('copilot-client').setup {
mapping = {
accept = '<CR>',
-- Next and previos suggestions to be added
-- suggest_next = '<C-n>',
-- suggest_prev = '<C-p>',
},
}
-- Create a keymap that triggers the suggestion. To accept suggestion press <CR> as set in the setup.
vim.api.nvim_set_keymap('i', '<C-c>', '<cmd>lua require("copilot-client").suggest()<CR>', { noremap = true, silent = true })
- Client that requests suggestions from the Language Server periodically like the standard Github Copilot plugin. (Maybe not because it looks like copilot.lua is going to implement it and I think that is a good idea)
- Multiple suggestions,
suggest_next
andsuggest_prev
functions - 'Waiting for copilot' as virtual dots instead of printing to the command line