cmp: add copilot as cmp source
This commit is contained in:
parent
1b8a4094d0
commit
75a7857913
|
@ -17,10 +17,20 @@ return {
|
||||||
dependencies = {
|
dependencies = {
|
||||||
'hrsh7th/cmp-nvim-lsp',
|
'hrsh7th/cmp-nvim-lsp',
|
||||||
'L3MON4D3/LuaSnip',
|
'L3MON4D3/LuaSnip',
|
||||||
'saadparwaiz1/cmp_luasnip'
|
'saadparwaiz1/cmp_luasnip',
|
||||||
|
|
||||||
|
{ -- copilot
|
||||||
|
'zbirenbaum/copilot.lua',
|
||||||
|
opts = { suggestion = { enabled = false }, panel = { enabled = false } }
|
||||||
|
},
|
||||||
|
|
||||||
|
{ -- copilot-cmp source
|
||||||
|
'zbirenbaum/copilot-cmp',
|
||||||
|
opts = { clear_after_cursor = true }
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
config = function ()
|
config = function()
|
||||||
-- nvim-cmp setup
|
-- nvim-cmp setup
|
||||||
local cmp = require 'cmp'
|
local cmp = require 'cmp'
|
||||||
local luasnip = require 'luasnip'
|
local luasnip = require 'luasnip'
|
||||||
|
@ -34,7 +44,7 @@ return {
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
mapping = cmp.mapping.preset.insert {
|
mapping = cmp.mapping.preset.insert {
|
||||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
['<C-d>'] = cmp.mapping.scroll_docs( -4),
|
||||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||||
['<C-Space>'] = cmp.mapping.complete {},
|
['<C-Space>'] = cmp.mapping.complete {},
|
||||||
['<CR>'] = cmp.mapping.confirm {
|
['<CR>'] = cmp.mapping.confirm {
|
||||||
|
@ -53,8 +63,8 @@ return {
|
||||||
['<S-Tab>'] = cmp.mapping(function(fallback)
|
['<S-Tab>'] = cmp.mapping(function(fallback)
|
||||||
if cmp.visible() then
|
if cmp.visible() then
|
||||||
cmp.select_prev_item()
|
cmp.select_prev_item()
|
||||||
elseif luasnip.jumpable(-1) then
|
elseif luasnip.jumpable( -1) then
|
||||||
luasnip.jump(-1)
|
luasnip.jump( -1)
|
||||||
else
|
else
|
||||||
fallback()
|
fallback()
|
||||||
end
|
end
|
||||||
|
@ -63,6 +73,7 @@ return {
|
||||||
sources = {
|
sources = {
|
||||||
{ name = 'nvim_lsp' },
|
{ name = 'nvim_lsp' },
|
||||||
{ name = 'luasnip' },
|
{ name = 'luasnip' },
|
||||||
|
{ name = 'copilot' },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue