^0.5 is broken for LanguageClient-neovim, likely others
See original GitHub issueFirst, thanks for this language server. It’s awesome and I look forward to it becoming even more awesome.
Problem
A combination of changes between 0.4.1 and 0.5.0 broke compatibility with my LSP client (LanguageClient-neovim, latest version, commit hash ee6cdb0940d9c2c95f31488f7d463b2d12abcbc4. Using neovim 0.5.0 dev). I suspect it’s broken for other Vim/neovim clients as well.
Error with yaml-language-server version ^0.5
“Cannot read property 'hierarchicalDocumentSymbolSupport' of undefined”
Plethora of problems
Line 351 of src/server.ts contains the following line:
hierarchicalDocumentSymbolSupport = !!capabilities.textDocument.documentSymbol.hierarchicalDocumentSymbolSupport;
This errors out when the server capabilities does not contain a documentSymbol. The LSP specification allows a client to omit this information, but the yaml-language-server does not elegantly handle this case (hierarchicalDocumentSymbolSupport is called on the undefined “documentSymbol” attribute).
I tried updating this line to:
hierarchicalDocumentSymbolSupport = !!(capabilities.textDocument.documentSymbol && capabilities.textDocument.documentSymbol.hierarchicalDocumentSymbolSupport);
But now I receive a new error:
[LC] [Error] Notification handler 'workspace/didChangeConfiguration' failed with message: workspaceFolders is not iterable
Therefore, the remedy is more complex than simply catching the “undefined” case.
Full original error message
WARN unnamed src/language_server_protocol.rs:2217 Failed to start language server automatically. Error: Failure { jsonrpc: Some(V2), error: Error { code: InternalError, message: "Request intialize failed with message: Cannot read property \'hierarchicalDocumentSymbolSupport\' of undefined", data: None }, id: Num(1) }
Evidence from coc.nvim
Coc’s yaml extension pins this library to 0.4.0, which strengthens my suspicion that yaml-language-server is broken for other vim language clients; coc users wouldn’t notice the breakage because they don’t use the latest version.
https://github.com/neoclide/coc-yaml/blob/master/package.json
"dependencies": {
"yaml-language-server": "^0.4.0"
}
Reference
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (6 by maintainers)
Perhaps something as blunt as:
I’ve just released 0.6.0 which contains these fixes!