add copilot

pull/911/head
Aki Wu 3 weeks ago
parent dc577b564f
commit 21c565534d

@ -697,6 +697,31 @@ require('lazy').setup({
-- into multiple repos for maintenance purposes.
'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-path',
-- copilot cmp source, aki
{
'zbirenbaum/copilot-cmp',
dependencies = 'copilot.lua',
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
local on_attach = function(client, _)
if client.name == 'copilot' then
copilot_cmp._on_insert_enter {}
end
end
vim.api.nvim_create_autocmd('LspAttach', {
callback = function(args)
local buffer = args.buf ---@type number
local client = vim.lsp.get_client_by_id(args.data.client_id)
on_attach(client, buffer)
end,
})
end,
},
},
config = function()
-- See `:help cmp`
@ -768,6 +793,7 @@ require('lazy').setup({
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'path' },
{ name = 'copilot', group_index = 1, priority = 100 },
},
}
end,
@ -885,7 +911,7 @@ require('lazy').setup({
--
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
-- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins`
-- { import = 'custom.plugins' },
{ import = 'custom.plugins' },
}, {
ui = {
-- If you are using a Nerd Font: set icons to an empty table which will use the

@ -0,0 +1,23 @@
return {
'zbirenbaum/copilot-cmp',
dependencies = 'copilot.lua',
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
local on_attach = function(client, _)
if client.name == 'copilot' then
copilot_cmp._on_insert_enter {}
end
end
vim.api.nvim_create_autocmd('LspAttach', {
callback = function(args)
local buffer = args.buf ---@type number
local client = vim.lsp.get_client_by_id(args.data.client_id)
on_attach(client, buffer)
end,
})
end,
}

@ -0,0 +1,13 @@
return {
'zbirenbaum/copilot.lua',
cmd = 'Copilot',
build = ':Copilot auth',
opts = {
suggestion = { enabled = false },
panel = { enabled = false },
filetypes = {
markdown = true,
help = true,
},
},
}
Loading…
Cancel
Save