configure copilot

This commit is contained in:
Ray Elliott 2025-12-07 22:03:35 +00:00
parent 9a81bc88cf
commit c47afa2471
4 changed files with 43 additions and 10 deletions

View File

@ -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

View File

@ -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" },

View File

@ -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({
["<C-Space>"] = cmp.mapping.complete(),
["<CR>"] = cmp.mapping.confirm({ select = false }),
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Auto-select first item
["<C-n>"] = cmp.mapping.select_next_item(),
["<C-p>"] = cmp.mapping.select_prev_item(),
["<C-e>"] = 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)

22
lua/plugins/copilot.lua Normal file
View File

@ -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,
},
}