completion-nvim icon indicating copy to clipboard operation
completion-nvim copied to clipboard

completion.lua autocommand overwriting custom <CR> imap

Open taylan97 opened this issue 5 years ago • 0 comments

I was setting a custom imap for <CR> in a floating window buffer. It would work the first time, but when I left the buffer then re-enter, it would stop functioning. I discovered that completion.nvim was overwriting my own map with it's completion mapping.

Because they both map to the same key in the buffer (<CR>), there wasn't any chance for say, recursive fall through to make your <CR> trigger my <CR> (at least that's my impression).

Now I know I can either rebind the completion key to something else, or not attach completion.nvim to all buffers, but I would prefer to not do either of those things.

One solution was to just set unique = true on the completion map, but that drops an error, and I'm not good enough at lua or vim to know how to stop those from bubbling up (pcall did catch the error, but didn't stop the error messages showing up).

So instead I started checking to see if an bind exists, and if it does, simply skip the completion binding.

I'm not 100% sure this should be even considered a bug, so I haven't provided a slim configuration and repro instructions, but if it is a bug I can make one of those if desired.

I don't know how to use GitHub but my fix is on this branch: https://github.com/taylan97/completion-nvim/tree/completion-imap-no-clobber, in this file: https://github.com/taylan97/completion-nvim/blob/completion-imap-no-clobber/lua/completion.lua#L255-L282

taylan97 avatar Oct 25 '20 11:10 taylan97