fix Coc completion with autopairs
This commit is contained in:
parent
daf765a66d
commit
c064362163
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue