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

completion.lua autocommand overwriting custom <CR> imap #255

@taylan97

Description

@taylan97

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 (), there wasn't any chance for say, recursive fall through to make your trigger my (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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions