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.coding.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 = false },
panel = { enabled = false },
filetypes = {
markdown = true,
help = true,
},
}

nvim-cmp

copilot cmp source

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

copilot-cmp

opts = {}

lualine.nvim (optional)

opts = function(_, opts)
local colors = {
[""] = LazyVim.ui.fg("Special"),
["Normal"] = LazyVim.ui.fg("Special"),
["Warning"] = LazyVim.ui.fg("DiagnosticError"),
["InProgress"] = LazyVim.ui.fg("DiagnosticWarn"),
}
table.insert(opts.sections.lualine_x, 2, {
function()
local icon = require("lazyvim.config").icons.kinds.Copilot
local status = require("copilot.api").status.data
return icon .. (status.message or "")
end,
cond = function()
if not package.loaded["copilot"] then
return
end
local ok, clients = pcall(LazyVim.lsp.get_clients, { name = "copilot", bufnr = 0 })
if not ok then
return false
end
return ok and #clients > 0
end,
color = function()
if not package.loaded["copilot"] then
return
end
local status = require("copilot.api").status.data
return colors[status.status] or colors[""]
end,
})
end