mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-21 20:11:06 +00:00
feat: copilot.nvim
This commit is contained in:
parent
92b7fcf7b1
commit
493e8666a6
1 changed files with 23 additions and 14 deletions
|
|
@ -16,7 +16,6 @@ if LazyVim.has_extra("ai.copilot-native") then
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.g.ai_cmp = false
|
vim.g.ai_cmp = false
|
||||||
local status = {} ---@type table<number, "ok" | "error" | "pending">
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
desc = "Native Copilot LSP integration. Requires Neovim >= 0.12",
|
desc = "Native Copilot LSP integration. Requires Neovim >= 0.12",
|
||||||
|
|
@ -26,17 +25,6 @@ return {
|
||||||
opts = {
|
opts = {
|
||||||
servers = {
|
servers = {
|
||||||
copilot = {
|
copilot = {
|
||||||
handlers = {
|
|
||||||
didChangeStatus = function(err, res, ctx)
|
|
||||||
if err then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
status[ctx.client_id] = res.kind ~= "Normal" and "error" or res.busy and "pending" or "ok"
|
|
||||||
if res.status == "Error" then
|
|
||||||
LazyVim.error("Please use `:LspCopilotSignIn` to sign in to Copilot")
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
-- stylua: ignore
|
-- stylua: ignore
|
||||||
keys = {
|
keys = {
|
||||||
{
|
{
|
||||||
|
|
@ -60,6 +48,11 @@ return {
|
||||||
|
|
||||||
-- Accept inline suggestions or next edits
|
-- Accept inline suggestions or next edits
|
||||||
LazyVim.cmp.actions.ai_accept = function()
|
LazyVim.cmp.actions.ai_accept = function()
|
||||||
|
local Nes = require("copilot.nes")
|
||||||
|
if Nes.have() and (Nes.jump() or Nes.apply()) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
if vim.lsp.inline_completion.get() then
|
if vim.lsp.inline_completion.get() then
|
||||||
-- nes_update() -- ensure nes update is triggered after inline completion
|
-- nes_update() -- ensure nes update is triggered after inline completion
|
||||||
return true
|
return true
|
||||||
|
|
@ -80,10 +73,26 @@ return {
|
||||||
opts.sections.lualine_x,
|
opts.sections.lualine_x,
|
||||||
2,
|
2,
|
||||||
LazyVim.lualine.status(LazyVim.config.icons.kinds.Copilot, function()
|
LazyVim.lualine.status(LazyVim.config.icons.kinds.Copilot, function()
|
||||||
local clients = vim.lsp.get_clients({ name = "copilot", bufnr = 0 })
|
local status = require("copilot.status").get()
|
||||||
return #clients > 0 and status[clients[1].id] or nil
|
if status then
|
||||||
|
return status.kind == "Error" and "error" or status.busy and "pending" or "ok"
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
)
|
)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"folke/copilot.nvim",
|
||||||
|
init = function()
|
||||||
|
LazyVim.cmp.actions.ai_stop = function()
|
||||||
|
require("copilot").hide()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
opts = {},
|
||||||
|
keys = {
|
||||||
|
-- nes is also useful in normal mode
|
||||||
|
{ "<tab>", LazyVim.cmp.map({ "ai_accept" }, "<tab>"), mode = { "n" }, expr = true },
|
||||||
|
},
|
||||||
|
} or nil,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue