question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

^0.5 is broken for LanguageClient-neovim, likely others

See original GitHub issue

First, 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:closed
  • Created 4 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
bollwyvlcommented, Oct 10, 2019

Perhaps something as blunt as:

    workspaceFolders = params.workspaceFolders || [];

    try {
        hierarchicalDocumentSymbolSupport = !!capabilities.textDocument.documentSymbol.hierarchicalDocumentSymbolSupport;
    } catch { }

    try {
        clientDynamicRegisterSupport = !!(capabilities.textDocument.rangeFormatting && capabilities.textDocument.rangeFormatting.dynamicRegistration);
    } catch { }
0reactions
JPinkneycommented, Nov 15, 2019

I’ve just released 0.6.0 which contains these fixes!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Neovim (0.5) Is Overpowering - CrispDev
There are various reasons. Firstly, Neovim is a drop-in Vim, so even the plugins could compat each other without much modification, if it...
Read more >
What Language-Server client does everyone use? : r/vim
I think LanguageClient-neovim was close, but was nvim only at the time and I was using vim. I haven't done much comparison to...
Read more >
Neovim v0.5 | Hacker News
I just switched from 0.4 to 0.5 specifically for LSP and treesitter support. There is zero difference between it and vscode for me...
Read more >
neoclide/coc.nvim - Gitter
Hey all, I'm experimenting with coc and rust-analyzer. I'm coming from a year or so of Rust development with LanguageClient-neovim combined with rls...
Read more >
Haskell Error Checking and Autocompletion With LSP
The package Haskell Language Server provides language client support to Visual Studio Code. Neovim. First, set up vim-plug as per the GitHub ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found