rcarriga / cmp-dap

nvim-cmp source for nvim-dap REPL and nvim-dap-ui buffers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when `supportsCompletionsRequest` is not supported

megawubs opened this issue · comments

After playing with this plugin and diving into the source I've finally figured out why this did not work for me. I'm using PHP and the PHP debug adapter (https://github.com/xdebug/vscode-php-debug/) does not support supportsCompletionsRequest.

When it does not support the completions request I assume the plugin should just do nothing but it gives the following error:

Error executing vim.schedule lua callback: ...e/pack/packer/start/cmp-buffer/lua/cmp_buffer/buffer.lua:356: bad argument #1 to 'ipairs' (table expected, got userdata)
stack traceback:
        [C]: in function 'ipairs'
        ...e/pack/packer/start/cmp-buffer/lua/cmp_buffer/buffer.lua:356: in function 'rebuild_unique_words'
        ...e/pack/packer/start/cmp-buffer/lua/cmp_buffer/buffer.lua:341: in function 'get_words'
        ...e/pack/packer/start/cmp-buffer/lua/cmp_buffer/source.lua:66: in function ''
        vim/_editor.lua: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

It happens sometimes when I type in the REPL window. When I disable the plugin, the error is gone.

This is not an error for cmp-dap, it does check that the capability is there.
This is cmp-buffer throwing the error cmp-buffer/lua/cmp_buffer/buffer.lua.

My guess is that it assumes you're not using prompt buffers and there's an issue with having completion enabled in them

[...] the debug adapter [...] does not support supportsCompletionsRequest

Hey @rcarriga, is there another way to get completion if the adapter doesn't support this request?

Hey @rcarriga, is there another way to get completion if the adapter doesn't support this request?

Theoretically you could use the variables DAP request to build a list of sources that would probably be valid. This would be a large enough task though. You'd have to handle caching so to not spam the adapter, handle invalidating that cache etc. I'm not using an adapter that doesn't provide completions so I don't have much interest in developing this but if someone wanted to submit a PR I'd be happy to help.

Closing this as it's an issue with another plugin