Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

[WIP] Make <CR> "extensible" for other plugins. #202

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lua/completion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,14 @@ M.on_attach = function(option)
api.nvim_command("autocmd CompleteDone <buffer> 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', '<Plug>(completion_confirm_expr)',
'pumvisible() ? complete_info()["selected"] != "-1" ? "\\<Plug>(completion_confirm_completion)" :'..
' "\\<c-e>\\<CR>" : "\\<CR>"',
{silent=false, noremap=false, expr=true})
' "\\<C-e>" : empty(maparg("\\'..opt.get_option('confirm_key')..'", "i")) ? "\\<CR>" : ""',
{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')..'<Plug>(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
Expand Down