From c47afa247185533e780e76d1c340df4b16f80cee Mon Sep 17 00:00:00 2001 From: ray Date: Sun, 7 Dec 2025 22:03:35 +0000 Subject: [PATCH] configure copilot --- MIGRATION_PLAN.md | 17 ++++++++++++----- lazy-lock.json | 2 ++ lua/plugins/cmp.lua | 12 +++++++----- lua/plugins/copilot.lua | 22 ++++++++++++++++++++++ 4 files changed, 43 insertions(+), 10 deletions(-) create mode 100644 lua/plugins/copilot.lua diff --git a/MIGRATION_PLAN.md b/MIGRATION_PLAN.md index 7b9dee8..72081b6 100644 --- a/MIGRATION_PLAN.md +++ b/MIGRATION_PLAN.md @@ -242,13 +242,20 @@ Source of truth for the step-by-step rebuild. Keep this concise and up to date. ## Phase 8 — Copilot ## Phase 8.1 — Confirm scope and priorities -- [ ] Confirm scope and priorities for this phase +- [x] Confirm scope and priorities for this phase +- [x] Decision: Integrate Copilot into nvim-cmp as completion source +- [x] Decision: Auto-trigger suggestions as you type +- [x] Decision: No specific Copilot keymaps needed (use existing cmp keymaps) +- [x] Decision: Enable for all filetypes +- [x] Decision: Copilot suggestions appear before LSP suggestions in completion menu +- [x] Node.js v22.21.1 upgraded and confirmed working ## Phase 8.2 — Copilot setup -- [ ] Add `zbirenbaum/copilot.lua` + `copilot-cmp` -- [ ] Configure copilot integration with nvim-cmp -- [ ] Add keymaps for copilot suggestions -- [ ] Configure behavior preferences +- [x] Add `zbirenbaum/copilot.lua` + `zbirenbaum/copilot-cmp` +- [x] Configure copilot.lua with auto-trigger and all filetypes +- [x] Add copilot-cmp as source to nvim-cmp +- [x] Set copilot-cmp priority higher than LSP in completion menu +- [x] Note: Copilot initializes on first InsertEnter; enter/exit insert mode once before using `:Copilot auth` ## Phase 9 — Formatting & Linting diff --git a/lazy-lock.json b/lazy-lock.json index c217699..d7f4182 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -4,6 +4,8 @@ "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, "cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" }, "cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" }, + "copilot-cmp": { "branch": "master", "commit": "15fc12af3d0109fa76b60b5cffa1373697e261d1" }, + "copilot.lua": { "branch": "master", "commit": "efe563802a550b7f1b7743b007987e97cba22718" }, "gitsigns.nvim": { "branch": "main", "commit": "5813e4878748805f1518cee7abb50fd7205a3a48" }, "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" }, "lazy.nvim": { "branch": "main", "commit": "85c7ff3711b730b4030d03144f6db6375044ae82" }, diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index acd1549..3239f29 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -6,6 +6,7 @@ return { "hrsh7th/cmp-buffer", "hrsh7th/cmp-path", "L3MON4D3/LuaSnip", + "zbirenbaum/copilot-cmp", -- Copilot completion source }, opts = function() local cmp = require("cmp") @@ -19,17 +20,18 @@ return { }, mapping = cmp.mapping.preset.insert({ [""] = cmp.mapping.complete(), - [""] = cmp.mapping.confirm({ select = false }), + [""] = cmp.mapping.confirm({ select = true }), -- Auto-select first item [""] = cmp.mapping.select_next_item(), [""] = cmp.mapping.select_prev_item(), [""] = cmp.mapping.abort(), }), sources = cmp.config.sources({ - { name = "nvim_lsp" }, - { name = "path" }, - { name = "buffer" }, + { name = "copilot", group_index = 2 }, -- Copilot suggestions (priority 1) + { name = "nvim_lsp", group_index = 2 }, + { name = "path", group_index = 2 }, + { name = "buffer", group_index = 2 }, }), - completion = { completeopt = "menu,menuone,noselect" }, + completion = { completeopt = "menu,menuone,noinsert" }, -- Auto-select first item } end, config = function(_, opts) diff --git a/lua/plugins/copilot.lua b/lua/plugins/copilot.lua new file mode 100644 index 0000000..87337d7 --- /dev/null +++ b/lua/plugins/copilot.lua @@ -0,0 +1,22 @@ +-- GitHub Copilot: AI-powered code completion +return { + { + 'zbirenbaum/copilot.lua', + cmd = 'Copilot', + event = 'InsertEnter', -- Lazy load on first insert mode entry + opts = { + suggestion = { enabled = false }, -- Disable inline suggestions (use cmp instead) + panel = { enabled = false }, -- Disable panel (use cmp instead) + filetypes = { + ['*'] = true, -- Enable for all filetypes + }, + }, + }, + { + 'zbirenbaum/copilot-cmp', + dependencies = { 'zbirenbaum/copilot.lua' }, + config = function() + require('copilot_cmp').setup() + end, + }, +}