<cr> mapping breaks abbreviations
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.
@joshuarubin You can use the following mapping.
cmp.setup {
['<CR>'] = cmp.mapping.confirm({ select = false })
}
Thank you. I will try that. My config is a bit more complicated (as linked above) though and the section that is broken (in the <cr> mapping, which is a function) looks like this:
-- fallback to normal <cr>
-- TODO(jawa) this breaks abbreviations :-(
fallback()
vim.fn.feedkeys(t "<plug>Endwise")
so there is no option for me to modify the select param.
do you have a suggestion on how I can modify this to fix the abbreviations? this block is only entered if no popup menu is visible and the text is not an expandable snippet.
thanks so much!
@joshuarubin I think you don't need to call vim.fn.feedkeys(t "<plug>Endwise"). (it will be invoked by fallback()
thanks, but I have vim.g.endwise_no_mappings = 1 so that it doesn't create mappings by default. anyway, I don't think that's what's causing the problem.
I've understand. But it is too difficult. Thank you for your report. I will investigate it.
I've fixed it maybe. Thank you!
The fix you put in place breaks Telescope (which is the issue I had when I tried the same thing)
https://github.com/neovim/neovim/issues/16854
Hm... it seems stil this problem exists.
Have you managed to fix this? I'm facing the same problem on my setup and can't figure it out what's going on.
Also having the exact same issue. Somehow, fallback fails to expand the abbreviation. When replacing the fallback with a custom feedkey sequence the issue is resolved, however, other plugins start to break (fugitive in my came).