vim-lsp icon indicating copy to clipboard operation
vim-lsp copied to clipboard

Errors when using vim with g:lsp_use_native_client: "Invalid value for argument id" in lsp#client#send_response()

Open mageta opened this issue 10 months ago • 4 comments

When I use the option g:lsp_use_native_client = 1 in vim I get frequent error-messages in my editor such as this:

Error detected while processing function <SNR>159_native_out_cb[7]..<SNR>131_on_request[19]..<SNR>131_send_response[4]..lsp#client#send_response:
line    8:
E475: Invalid value for argument id
E475: Invalid value for argument id
E475: Invalid value for argument id
E475: Invalid value for argument id
E475: Invalid value for argument id
E475: Invalid value for argument id

Additionally, it slows down, even blocks input in the editor quite heavily, which makes it more or less unusable. If I disable this option with g:lsp_use_native_client = 0 things work fine.

vim-lsp still seems to work for some parts. Diagnostics get displayed, omni completions work, but everything is slow due to the errors.

I'm not sure how to debug this further, sorry. Not an expert on vim scripting/debugging.

Version information:

Vim 9.0, patches 1-1777 Vim-lsp: 7233bb2ec07506b6a6e57dfe4541f1c4e5647fd2 ("Add LspAddTreeReferences (#1484)")

Please tell if/what other information you need.

mageta avatar Sep 25 '23 17:09 mageta

Just remembered, one thing I changed last week was to enable g:lsp_work_done_progress_enabled = 1. And indeed, if I disable this again, the errors go away, even with g:lsp_use_native_client = 1. This might also be related to the language server used.

When I tested this settings last week, I was using clangd on some C source base. It seemed to work fine then - that is, both these settings set to 1. Yesterday I was working on a Python source base with python-lsp-server as server, which gave me the errors as I've described initially.

I hope this can narrow it down a bit.

mageta avatar Sep 26 '23 08:09 mageta

Got this while running pylsp-all and digging further seems like the issue only occurs when g:lsp_use_native_client is enabled and the client needs to send response. I primarily use rust and don't have issues with lsp_work_done_progress_enabled. Upon further investigations noticed that the rust returns the id as integer while pylsp-all returns the id as string which is not supported. The solution would be to either disable lsp_use_native_client or lsp_work_done_progress_enabled.

I have verified that vim only supports id as number.

https://github.com/vim/vim/blob/d086b8f646a67f6b16c46061ce773de1011b8ec7/src/channel.c#L4509C1-L4515C3

Filed a bug in vim. https://github.com/vim/vim/issues/14091

prabirshrestha avatar Feb 25 '24 10:02 prabirshrestha

While the bug is in vim, I have added try..catch to hide the error. Please try the latest master.

prabirshrestha avatar Feb 25 '24 11:02 prabirshrestha

Thanks for digging into this! I pulled a new version with the workaround included, and can confirm the error messages are gone; both clangd and python-lsp-server work now - clangd can also display the progress information again that I had to disable.

You want me to close the bug with that, or keep it open to track the vim issue?

mageta avatar Feb 29 '24 16:02 mageta