- TextDocument Focusing
- Inline Completion
- Next Edit Suggestion
- Uses native LSP Binary
- Sign In Flow
- Status Notification
To use the plugin, add the following to your Neovim configuration:
return {
"copilotlsp-nvim/copilot-lsp",
init = function()
vim.g.copilot_nes_debounce = 500
vim.lsp.enable("copilot_ls")
vim.keymap.set("n", "<tab>", function()
-- Try to jump to the start of the suggestion edit.
-- If already at the start, then apply the pending suggestion and jump to the end of the edit.
local _ = require("copilot-lsp.nes").walk_cursor_start_edit()
or (
require("copilot-lsp.nes").apply_pending_nes() and require("copilot-lsp.nes").walk_cursor_end_edit()
)
end)
end,
}
You can map the <Esc>
key to clear suggestions while preserving its other functionality:
-- Clear copilot suggestion with Esc if visible, otherwise preserve default Esc behavior
vim.keymap.set("n", "<esc>", function()
if not require('copilot-lsp.nes').clear() then
-- fallback to other functionality
end
end, { desc = "Clear Copilot suggestion or fallback" })
You don’t need to configure anything, but you can customize the defaults:
move_count_threshold
is the most important. It controls how many cursor moves happen before suggestions are cleared. Higher = slower to clear.
require('copilot-lsp').setup({
nes = {
move_count_threshold = 3, -- Clear after 3 cursor movements
}
})
return {
keymap = {
preset = "super-tab",
["<Tab>"] = {
function(cmp)
if vim.b[vim.api.nvim_get_current_buf()].nes_state then
cmp.hide()
return (
require("copilot-lsp.nes").apply_pending_nes()
and require("copilot-lsp.nes").walk_cursor_end_edit()
)
end
if cmp.snippet_active() then
return cmp.accept()
else
return cmp.select_and_accept()
end
end,
"snippet_forward",
"fallback",
},
},
}
It can also be combined with fang2hou/blink-copilot to get inline completions. Just add the completion source to your Blink configuration and it will integrate
- Copilot LSP installed via Mason or system and on PATH