From d54442399f1596f1c780193e71dfc4c21d85aac4 Mon Sep 17 00:00:00 2001 From: Nolan Prochnau Date: Wed, 9 Sep 2020 22:04:04 -0400 Subject: [PATCH] Mostly get working correctly Got every case except when the menu is visible and nothing is selected. You have to hit twice to trigger previous mapping. --- lua/completion.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lua/completion.lua b/lua/completion.lua index baa5e12..1d6c41e 100644 --- a/lua/completion.lua +++ b/lua/completion.lua @@ -224,10 +224,14 @@ M.on_attach = function(option) api.nvim_command("autocmd CompleteDone lua require'completion'.on_CompleteDone()") api.nvim_command("augroup end") if string.len(opt.get_option('confirm_key')) ~= 0 then - api.nvim_buf_set_keymap(0, 'i', opt.get_option('confirm_key'), + api.nvim_set_keymap('i', '(completion_confirm_expr)', 'pumvisible() ? complete_info()["selected"] != "-1" ? "\\(completion_confirm_completion)" :'.. - ' "\\\\" : "\\"', - {silent=false, noremap=false, expr=true}) + ' "\\" : empty(maparg("\\'..opt.get_option('confirm_key')..'", "i")) ? "\\" : ""', + {silent=false, noremap=true, expr=true}) + + api.nvim_buf_set_keymap(0, 'i', opt.get_option('confirm_key'), + vim.fn.maparg(opt.get_option('confirm_key'), 'i')..'(completion_confirm_expr)', + {silent=false, noremap=false}) end -- overwrite vsnip_integ autocmd since we handle it on ourself in confirmCompletion if vim.fn.exists("#vsnip_integ") then