From e6d978fc38fd74b5bfa54d1057f0579fc146c615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20=C5=A0tefka?= Date: Sat, 29 Oct 2022 23:55:17 +0200 Subject: [PATCH] Make copilot work with cmp --- init.lua | 7 +++++-- plugins/cmp.lua | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 plugins/cmp.lua diff --git a/init.lua b/init.lua index bc34760..c766ca3 100644 --- a/init.lua +++ b/init.lua @@ -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 = { -- [""] = false, }, i = { - [""] = { "copilot#Accept('')", silent = true, expr = true }, + -- [""] = { "copilot#Accept('')", silent = true, expr = true }, } }, @@ -292,7 +295,7 @@ local config = { -- end, -- }, -- - { + { "folke/todo-comments.nvim", event = "BufRead", config = function() diff --git a/plugins/cmp.lua b/plugins/cmp.lua new file mode 100644 index 0000000..b247eed --- /dev/null +++ b/plugins/cmp.lua @@ -0,0 +1,25 @@ +local cmp = require "cmp" +local luasnip = require "luasnip" +return { + preselect = cmp.PreselectMode.None, + mapping = { + [""] = cmp.mapping.confirm { select = false }, + [""] = cmp.mapping(function(fallback) + vim.api.nvim_feedkeys(vim.fn['copilot#Accept'](vim.api.nvim_replace_termcodes('', 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. + } +}