ruby-lsp
ruby-lsp copied to clipboard
LSP response encoding of DocumentSelect is wrong: is DocumentFilter, should be DocumentFilter[]
Description
Hi,
I'm currently integrating ruby-lsp as an extension for the Nova editor and it raises an error early on because a response message couldn't be parsed.
Details and log can be found in the Nova Dev Forum here and also attached as a file here lsp-error.txt
This is what the offending response sent from ruby-lsp
looks like
"documentSelector" : {
"scheme" : "file",
"language" : "ruby"
},
which leads to this error in Nova:
"Expected to decode Array<Any> but found a dictionary instead."
Looking at the error and JSON-RPC it appears to me that Nova is right and your encoding of DocumentSelector is not conforming to the LSP spec , where it is defined as :
DocumentSelector export type = DocumentFilter[];
I'm not very well versed in ruby so I can't provide a properly built and tested pull request, but I think I've tracked it down to the following line in your source code:
/lib/ruby_lsp/requests/semantic_highlighting.rb#L32 is
document_selector: { scheme: "file", language: "ruby" },
I can make it work fine if I patch it locally in my installed ruby-lsp
gem to
document_selector: [ { scheme: "file", language: "ruby" } ],
obviously I couldn't test for any regressions, but I hope you can include a fix soon in an upcoming release
thanks, O