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
- Options
- Full Spec
opts = {
suggestion = { enabled = false },
panel = { enabled = false },
filetypes = {
markdown = true,
help = true,
},
}
{
"zbirenbaum/copilot.lua",
cmd = "Copilot",
build = ":Copilot auth",
opts = {
suggestion = { enabled = false },
panel = { enabled = false },
filetypes = {
markdown = true,
help = true,
},
},
}
nvim-cmp
copilot cmp source
- Options
- Full Spec
opts = function(_, opts)
table.insert(opts.sources, 1, {
name = "copilot",
group_index = 1,
priority = 100,
})
end
{
"nvim-cmp",
dependencies = {
{
"zbirenbaum/copilot-cmp",
dependencies = "copilot.lua",
opts = {},
config = function(_, opts)
local copilot_cmp = require("copilot_cmp")
copilot_cmp.setup(opts)
-- attach cmp source whenever copilot attaches
-- fixes lazy-loading issues with the copilot cmp source
LazyVim.lsp.on_attach(function(client)
copilot_cmp._on_insert_enter({})
end, "copilot")
end,
},
},
---@param opts cmp.ConfigSchema
opts = function(_, opts)
table.insert(opts.sources, 1, {
name = "copilot",
group_index = 1,
priority = 100,
})
end,
}
copilot-cmp
- Options
- Full Spec
opts = {}
{
"zbirenbaum/copilot-cmp",
dependencies = "copilot.lua",
opts = {},
config = function(_, opts)
local copilot_cmp = require("copilot_cmp")
copilot_cmp.setup(opts)
-- attach cmp source whenever copilot attaches
-- fixes lazy-loading issues with the copilot cmp source
LazyVim.lsp.on_attach(function(client)
copilot_cmp._on_insert_enter({})
end, "copilot")
end,
}
lualine.nvim (optional)
- Options
- Full Spec
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 = 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
{
"nvim-lualine/lualine.nvim",
optional = true,
event = "VeryLazy",
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 = 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,
}