hrsh7th/nvim-cmp

<cr> mapping breaks abbreviations

Open

#103 opened on Aug 27, 2021

View on GitHub
 (11 comments) (3 reactions) (0 assignees)Lua (9,420 stars) (437 forks)batch import
bugdifficulthelp wantedreproduced

Description

I don't think this is necessarily related to cmp, but I wanted to report it on the off chance it is or someone here knows how to fix it.

When I use any mapping for <cr>, my abbreviations stop working when using <cr> as the "non-keyword" character. I get this when using the suggested mapping like:

    ['<CR>'] = cmp.mapping.confirm({
      behavior = cmp.ConfirmBehavior.Insert,
      select = true,
    }),

but also in my more complicated mapping here.

An example would be to add this to your config:

iabbrev TODO TODO(jawa)

The expected behavior is in an empty document, in INSERT mode, type TODO then <cr>. This should cause the abbreviation to be expanded to TODO(jawa) with the cursor now on the next line.

This doesn't happen when I have the <cr> mapping specified, I just get TODO followed by the newline.

I tried adding vim.fn.feedkeys(t '<c-]><cr>') in my custom mapping function (instead of fallback()), which worked, but broke other things and wasn't something I could keep in place.

Any ideas would be much appreciated.

Contributor guide