yegappan / lsp

Language Server Protocol (LSP) plugin for Vim9
MIT License
458 stars 49 forks source link

Successful ResponseMessage with no content should have `"result": null`, not `"result": {}` #460

Closed silby closed 6 months ago

silby commented 6 months ago

Per the specification:

If a request doesn’t provide a result value the receiver of a request still needs to return a response message to conform to the JSON-RPC specification. The result property of the ResponseMessage should be set to null in this case to signal a successful request.

haskell-language-server complains when it gets an empty object instead.

LSP debug message transcript:

02/20/24 10:37:32: Received {'id': 4, 'jsonrpc': '2.0', 'method': 'window/workDoneProgress/create', 'params': {'token': '37'}}
02/20/24 10:37:32: Sent {'id': 4, 'jsonrpc': '2.0', 'result': {}}

haskell-language-server complaint:

2024-02-20T18:37:32.356511Z | Error | LSP: incoming message parse error:
Error in $.result: expected 'null'
when processing
{"id":4,"jsonrpc":"2.0","result":{}}

It would be more compliant with the spec to send "result": null here.

yegappan commented 6 months ago

Can you try changing the second parameter to null in https://github.com/yegappan/lsp/blob/main/autoload/lsp/handlers.vim#L193?

silby commented 6 months ago

Yes, that change makes HLS cease complaining, I see this debug transcript and no error from the language server:

02/20/24 23:02:15: Received {'id': 2, 'jsonrpc': '2.0', 'method': 'window/workDoneProgress/create', 'params': {'token': '18'}}
02/20/24 23:02:15: Sent {'id': 2, 'jsonrpc': '2.0', 'result': null}
yegappan commented 6 months ago

I have committed https://github.com/yegappan/lsp/commit/a4cdb9c723d83664fbad70ae070ea569459a2400 now to add this. Let me know if you see any additional issues with the latest plugin.