fix Coc completion with autopairs

This commit is contained in:
Christoph J. Scherr 2023-07-15 14:15:50 +02:00
parent daf765a66d
commit c064362163
Signed by: PlexSheep
GPG Key ID: 7CDD0B14851A08EF
1 changed files with 26 additions and 1 deletions

View File

@ -10,6 +10,31 @@ inoremap <silent><expr> <cr> coc#pum#visible() ? coc#pum#confirm() :
lua << EOF lua << EOF
require("nvim-autopairs").setup {} require("nvim-autopairs").setup {}
local Rule = require('nvim-autopairs.rule') local Rule = require('nvim-autopairs.rule')
local remap = vim.api.nvim_set_keymap
local npairs = require('nvim-autopairs') local npairs = require('nvim-autopairs')
npairs.add_rule(Rule("<>","<>","rs")) npairs.setup({map_cr=false})
-- skip it, if you use another global object
_G.MUtils= {}
-- old version
-- MUtils.completion_confirm=function()
-- if vim.fn["coc#pum#visible"]() ~= 0 then
-- return vim.fn["coc#_select_confirm"]()
-- else
-- return npairs.autopairs_cr()
-- end
-- end
-- new version for custom pum
MUtils.completion_confirm=function()
if vim.fn["coc#pum#visible"]() ~= 0 then
return vim.fn["coc#pum#confirm"]()
else
return npairs.autopairs_cr()
end
end
remap('i' , '<CR>','v:lua.MUtils.completion_confirm()', {expr = true , noremap = true})
EOF EOF