Make copilot work with cmp

This commit is contained in:
Jiří Štefka 2022-10-29 23:55:17 +02:00
parent eac04f8fca
commit e6d978fc38
2 changed files with 30 additions and 2 deletions

View file

@ -1,3 +1,6 @@
local cmp = require('cmp')
-- Never gonna give you up
-- Never gonna
-- AstroNvim Configuration Table
-- All configuration changes should go inside of the table below
@ -271,7 +274,7 @@ local config = {
-- ["<esc>"] = false,
},
i = {
["<C-e>"] = { "copilot#Accept('<CR>')", silent = true, expr = true },
-- ["<Tab>"] = { "copilot#Accept('<CR>')", silent = true, expr = true },
}
},
@ -292,7 +295,7 @@ local config = {
-- end,
-- },
--
{
{
"folke/todo-comments.nvim",
event = "BufRead",
config = function()

25
plugins/cmp.lua Normal file
View file

@ -0,0 +1,25 @@
local cmp = require "cmp"
local luasnip = require "luasnip"
return {
preselect = cmp.PreselectMode.None,
mapping = {
["<CR>"] = cmp.mapping.confirm { select = false },
["<Tab>"] = cmp.mapping(function(fallback)
vim.api.nvim_feedkeys(vim.fn['copilot#Accept'](vim.api.nvim_replace_termcodes('<Tab>', true, true, true)), 'n',
true)
end)
-- if luasnip.expandable() then
-- luasnip.expand()
-- elseif luasnip.expand_or_jumpable() then
-- luasnip.expand_or_jump()
-- fallback()
-- end
-- end, {
-- "i",
-- "s",
-- }),
},
experimental = {
ghost_text = false -- this feature conflict with copilot.vim's preview.
}
}