mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-07-11 18:04:32 +02:00
130 lines
3.3 KiB
Lua
130 lines
3.3 KiB
Lua
return {
|
|
recommended = true,
|
|
-- copilot
|
|
{
|
|
"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,
|
|
},
|
|
},
|
|
},
|
|
|
|
-- add ai_accept action
|
|
{
|
|
"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,
|
|
},
|
|
|
|
-- lualine
|
|
{
|
|
"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,
|
|
},
|
|
|
|
-- copilot cmp source
|
|
{
|
|
"nvim-cmp",
|
|
optional = true,
|
|
dependencies = { -- this will only be evaluated if nvim-cmp is enabled
|
|
{
|
|
"zbirenbaum/copilot-cmp",
|
|
enabled = vim.g.ai_cmp, -- only enable if wanted
|
|
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 = {
|
|
{
|
|
"nvim-cmp",
|
|
---@param opts cmp.ConfigSchema
|
|
opts = function(_, opts)
|
|
table.insert(opts.sources, 1, {
|
|
name = "copilot",
|
|
group_index = 1,
|
|
priority = 100,
|
|
})
|
|
end,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
|
|
-- blink.cmp
|
|
{
|
|
"saghen/blink.cmp",
|
|
optional = true,
|
|
opts = {
|
|
windows = { ghost_text = { enabled = false } },
|
|
},
|
|
specs = {
|
|
-- blink has no copilot source, so force enable suggestions
|
|
{
|
|
"zbirenbaum/copilot.lua",
|
|
opts = { suggestion = { enabled = true } },
|
|
},
|
|
},
|
|
},
|
|
}
|