Skip to main content

Copilot

info

You can enable the extra with the :LazyExtras command. Plugins marked as optional will only be configured if they are installed.

Alternatively, you can add it to your lazy.nvim imports
lua/config/lazy.lua
require("lazy").setup({
spec = {
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
{ import = "lazyvim.plugins.extras.ai.copilot" },
{ import = "plugins" },
},
})

Below you can find a list of included plugins and their default settings.

caution

You don't need to copy the default settings to your config. They are only shown here for reference.

copilot.lua

copilot

opts = {
suggestion = {
enabled = not vim.g.ai_cmp,
auto_trigger = true,
keymap = {
accept = false, -- handled by nvim-cmp / blink.cmp
next = "<M-]>",
prev = "<M-[>",
},
},
panel = { enabled = false },
filetypes = {
markdown = true,
help = true,
},
}

copilot.lua

add ai_accept action

opts = function()
LazyVim.cmp.actions.ai_accept = function()
if require("copilot.suggestion").is_visible() then
LazyVim.create_undo()
require("copilot.suggestion").accept()
return true
end
end
end

copilot-cmp

this will only be evaluated if nvim-cmp is enabled

opts = {}
opts = nil

lualine.nvim (optional)

lualine

opts = function(_, opts)
table.insert(
opts.sections.lualine_x,
2,
LazyVim.lualine.status(LazyVim.config.icons.kinds.Copilot, function()
local clients = package.loaded["copilot"] and LazyVim.lsp.get_clients({ name = "copilot", bufnr = 0 }) or {}
if #clients > 0 then
local status = require("copilot.api").status.data.status
return (status == "InProgress" and "pending") or (status == "Warning" and "error") or "ok"
end
end)
)
end

nvim-cmp (optional)

copilot cmp source

opts = nil

nvim-cmp (optional)

opts = function(_, opts)
table.insert(opts.sources, 1, {
name = "copilot",
group_index = 1,
priority = 100,
})
end

blink.cmp (optional)

blink.cmp

opts = nil

blink.cmp (optional)

opts = {
sources = {
providers = {
copilot = { name = "copilot", module = "blink-cmp-copilot" },
},
completion = {
enabled_providers = { "copilot" },
},
},
}