Copilot
info
You can enable the extra with the :LazyExtras
command.
Plugins marked as optional will only be configured if they are installed.
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 = 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,
},
}
{
"zbirenbaum/copilot.lua",
cmd = "Copilot",
build = ":Copilot auth",
event = "InsertEnter",
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
- Options
- Full Spec
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
{
"zbirenbaum/copilot.lua",
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
- Options
- Full Spec
opts = {}
{
"zbirenbaum/copilot-cmp",
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()
copilot_cmp._on_insert_enter({})
end, "copilot")
end,
specs = {
{
"hrsh7th/nvim-cmp",
optional = true,
---@param opts cmp.ConfigSchema
opts = function(_, opts)
table.insert(opts.sources, 1, {
name = "copilot",
group_index = 1,
priority = 100,
})
end,
},
},
}
blink-cmp-copilot
- Options
- Full Spec
opts = nil
{ "giuxtaposition/blink-cmp-copilot" }
lualine.nvim (optional)
lualine
- Options
- Full Spec
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-lualine/lualine.nvim",
optional = true,
event = "VeryLazy",
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
- Options
- Full Spec
opts = nil
{
"hrsh7th/nvim-cmp",
optional = true,
dependencies = { -- this will only be evaluated if nvim-cmp is enabled
{
"zbirenbaum/copilot-cmp",
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()
copilot_cmp._on_insert_enter({})
end, "copilot")
end,
specs = {
{
"hrsh7th/nvim-cmp",
optional = true,
---@param opts cmp.ConfigSchema
opts = function(_, opts)
table.insert(opts.sources, 1, {
name = "copilot",
group_index = 1,
priority = 100,
})
end,
},
},
},
},
}
nvim-cmp (optional)
- Options
- Full Spec
opts = function(_, opts)
table.insert(opts.sources, 1, {
name = "copilot",
group_index = 1,
priority = 100,
})
end
{
"hrsh7th/nvim-cmp",
optional = true,
---@param opts cmp.ConfigSchema
opts = function(_, opts)
table.insert(opts.sources, 1, {
name = "copilot",
group_index = 1,
priority = 100,
})
end,
}
blink.cmp (optional)
- Options
- Full Spec
opts = {
sources = {
default = { "copilot" },
providers = {
copilot = {
name = "copilot",
module = "blink-cmp-copilot",
kind = "Copilot",
score_offset = 100,
async = true,
},
},
},
}
{
"saghen/blink.cmp",
optional = true,
dependencies = { "giuxtaposition/blink-cmp-copilot" },
opts = {
sources = {
default = { "copilot" },
providers = {
copilot = {
name = "copilot",
module = "blink-cmp-copilot",
kind = "Copilot",
score_offset = 100,
async = true,
},
},
},
},
}