hrsh7th/nvim-cmp

<cr> mapping breaks abbreviations

Open

#103 aperta il 27 ago 2021

Vedi su GitHub
 (11 commenti) (3 reazioni) (0 assegnatari)Lua (437 fork)batch import
bugdifficulthelp wantedreproduced

Metriche repository

Star
 (9420 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

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.

Guida contributor