cmp-cmdline icon indicating copy to clipboard operation
cmp-cmdline copied to clipboard

E220: Missing `}` error when typing `:e {`

Open wookayin opened this issue 3 years ago • 2 comments

E220 error

Config: used the default config.

-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
  mapping = cmp.mapping.preset.cmdline(),
  sources = cmp.config.sources({
    { name = 'path' }
  }, {
    { name = 'cmdline' }
  })
})

Type :e { and an error that is not handled properly will occur:

Error executing vim.schedule lua callback: Vim:E220: Missing }.
stack traceback:
        [C]: in function 'getcompletion'
        .../.vim/plugged/cmp-cmdline/lua/cmp_cmdline/init.lua:108: in function 'exec'
        .../.vim/plugged/cmp-cmdline/lua/cmp_cmdline/init.lua:158: in function 'complete'
        .../nvim-cmp/lua/cmp/source.lua:325: in function 'complete'
        .../nvim-cmp/lua/cmp/core.lua:289: in function 'complete'
        .../nvim-cmp/lua/cmp/core.lua:169: in function 'autoindent'
        .../nvim-cmp/lua/cmp/core.lua:161: in function 'on_change'
        .../nvim-cmp/lua/cmp/init.lua:312: in function 'callback'
        .../nvim-cmp/lua/cmp/utils/async.lua:136: in function <.../nvim-cmp/lua/cmp/utils/async.lua:134>

wookayin avatar Nov 26 '22 00:11 wookayin

Looks similar:

Error detected while processing TextChangedI Autocommands for "*":
Error executing lua callback: Vim:E220: Missing }.
stack traceback:
        [C]: in function 'getcompletion'
        ...cal/share/nvim/lazy/cmp-cmdline/lua/cmp_cmdline/init.lua:136: in function 'exec'
        ...cal/share/nvim/lazy/cmp-cmdline/lua/cmp_cmdline/init.lua:202: in function 'complete'
        .../will/.local/share/nvim/lazy/nvim-cmp/lua/cmp/source.lua:326: in function 'complete'
        /home/will/.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:299: in function 'complete'
        /home/will/.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:169: in function 'callback'
        /home/will/.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:229: in function 'autoindent'
        /home/will/.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:161: in function 'on_change'
        /home/will/.local/share/nvim/lazy/nvim-cmp/lua/cmp/init.lua:340: in function 'callback'
        ...local/share/nvim/lazy/nvim-cmp/lua/cmp/utils/autocmd.lua:49: in function 'emit'
        ...local/share/nvim/lazy/nvim-cmp/lua/cmp/utils/autocmd.lua:23: in function <...local/share/nvim/lazy/nvim-cmp/lua/cmp/utils/autocmd.lua:22>

willhansen avatar Jun 21 '24 05:06 willhansen

I'm getting very similar callstack as @willhansen with the exact same repro steps as OP, but I'm also encountering this issue outside of cmdline, while editing regular buffer. I do not have the "proper" repro steps for the regular buffer but it usually occurs when I insert the cursor after { and delete it with Backspace

Crash narrows down to this line: https://github.com/hrsh7th/cmp-cmdline/blob/d250c63aa13ead745e3a40f61fdd3470efde3923/lua/cmp_cmdline/init.lua#L136

and I was able to successfully debug it like so:

image

which basically tells that a following vim API call happens:

vim.fn.getcompletion("e {", 'cmdline')

and said snipped indeed causes our issue: E5108: Error executing lua Vim:E220: Missing }.

Now, I might be able to fix it since I already got so deep into it. I think that { and } just aren't properly escaped with \\? I'm also not entirely sure if this is a bug in cmp-cmdline, nvim-cmp or nvim itself. It could be just a problem occurring down here, but requiring fix elsewhere.

CC @hrsh7th Maybe this would be a quick fix for you with provided information?

sleeptightAnsiC avatar Jul 18 '24 23:07 sleeptightAnsiC