You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently cmp-cmdline does not check if the current cmdline content is valid for completion before calling vim.fn.getcompletion(), which can leads to errors, especially when there are unfinished regex patterns in the cmdline.
Consider the following use case where users are using :grep or :vimg to search for the pattern \(foo\)\@<!bar:
:grep /\(f
after typing f the following error occurs:
Error executing vim.schedule lua callback: Vim:E54: Unmatched \(
stack traceback:
[C]: in function 'getcompletion'
...e/pack/packages/opt/cmp-cmdline/lua/cmp_cmdline/init.lua:130: in function 'exec'
...e/pack/packages/opt/cmp-cmdline/lua/cmp_cmdline/init.lua:181: in function 'complete'
.../nvim/site/pack/packages/opt/nvim-cmp/lua/cmp/source.lua:330: in function 'complete'
...re/nvim/site/pack/packages/opt/nvim-cmp/lua/cmp/core.lua:302: in function 'complete'
...re/nvim/site/pack/packages/opt/nvim-cmp/lua/cmp/core.lua:170: in function 'autoindent'
...re/nvim/site/pack/packages/opt/nvim-cmp/lua/cmp/core.lua:162: in function 'on_change'
...re/nvim/site/pack/packages/opt/nvim-cmp/lua/cmp/init.lua:313: in function 'callback'
.../site/pack/packages/opt/nvim-cmp/lua/cmp/utils/async.lua:165: in function <.../site/pack/packages/opt/nvim-cmp/lua/cmp/utils/async.lua:163>
this can be reproduced by calling vim.fn.getcompletion('grep /\\(f', 'cmdline') directly:
Error executing vim.schedule lua callback: Vim:E869: (NFA) Unknown operator '\@
stack traceback:
[C]: in function 'getcompletion'
...e/pack/packages/opt/cmp-cmdline/lua/cmp_cmdline/init.lua:130: in function 'exec'
...e/pack/packages/opt/cmp-cmdline/lua/cmp_cmdline/init.lua:181: in function 'complete'
.../nvim/site/pack/packages/opt/nvim-cmp/lua/cmp/source.lua:330: in function 'complete'
...re/nvim/site/pack/packages/opt/nvim-cmp/lua/cmp/core.lua:302: in function 'complete'
...re/nvim/site/pack/packages/opt/nvim-cmp/lua/cmp/core.lua:170: in function 'autoindent'
...re/nvim/site/pack/packages/opt/nvim-cmp/lua/cmp/core.lua:162: in function 'on_change'
...re/nvim/site/pack/packages/opt/nvim-cmp/lua/cmp/init.lua:313: in function 'callback'
.../site/pack/packages/opt/nvim-cmp/lua/cmp/utils/async.lua:165: in function <.../site/pack/packages/opt/nvim-cmp/lua/cmp/utils/async.lua:163>
Since there's no convenient way to detect if a pattern can be completed without errors, I think the best we can do is to use pcall() to try to get the completion silently and continue only if no errors are triggered.
The text was updated successfully, but these errors were encountered:
Currently cmp-cmdline does not check if the current cmdline content is valid for completion before calling
vim.fn.getcompletion()
, which can leads to errors, especially when there are unfinished regex patterns in the cmdline.Consider the following use case where users are using
:grep
or:vimg
to search for the pattern\(foo\)\@<!bar
:after typing
f
the following error occurs:this can be reproduced by calling
vim.fn.getcompletion('grep /\\(f', 'cmdline')
directly:Similar errors for
\@
:after typing
<
, the following error occurs:Since there's no convenient way to detect if a pattern can be completed without errors, I think the best we can do is to use
pcall()
to try to get the completion silently and continue only if no errors are triggered.The text was updated successfully, but these errors were encountered: