From 493e8666a6d74e4d02ed87409f1884d7188a5e46 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 26 Sep 2025 12:12:47 +0200 Subject: [PATCH] feat: copilot.nvim --- .../plugins/extras/ai/copilot-native.lua | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/lua/lazyvim/plugins/extras/ai/copilot-native.lua b/lua/lazyvim/plugins/extras/ai/copilot-native.lua index 71a6a3ae..bef3370a 100644 --- a/lua/lazyvim/plugins/extras/ai/copilot-native.lua +++ b/lua/lazyvim/plugins/extras/ai/copilot-native.lua @@ -16,7 +16,6 @@ if LazyVim.has_extra("ai.copilot-native") then end vim.g.ai_cmp = false -local status = {} ---@type table return { desc = "Native Copilot LSP integration. Requires Neovim >= 0.12", @@ -26,17 +25,6 @@ return { opts = { servers = { 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 keys = { { @@ -60,6 +48,11 @@ return { -- Accept inline suggestions or next edits 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 -- nes_update() -- ensure nes update is triggered after inline completion return true @@ -80,10 +73,26 @@ return { opts.sections.lualine_x, 2, LazyVim.lualine.status(LazyVim.config.icons.kinds.Copilot, function() - local clients = vim.lsp.get_clients({ name = "copilot", bufnr = 0 }) - return #clients > 0 and status[clients[1].id] or nil + local status = require("copilot.status").get() + if status then + return status.kind == "Error" and "error" or status.busy and "pending" or "ok" + 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 + { "", LazyVim.cmp.map({ "ai_accept" }, ""), mode = { "n" }, expr = true }, + }, + } or nil, }