hrsh7th/nvim-cmp

<cr> mapping breaks abbreviations

Open

#103 geöffnet am 27. Aug. 2021

Auf GitHub ansehen
 (11 Kommentare) (3 Reaktionen) (0 zugewiesene Personen)Lua (437 Forks)batch import
bugdifficulthelp wantedreproduced

Repository-Metriken

Stars
 (9.420 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

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