hrsh7th/nvim-cmp

<cr> mapping breaks abbreviations

Open

#103 ouverte le 27 août 2021

Voir sur GitHub
 (11 commentaires) (3 réactions) (0 assignés)Lua (437 forks)batch import
bugdifficulthelp wantedreproduced

Métriques du dépôt

Stars
 (9 420 stars)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

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.

Guide contributeur