Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No diagnostics for vscode-langservers-extracted #5547

Closed
luetage opened this issue Jan 15, 2023 · 21 comments
Closed

No diagnostics for vscode-langservers-extracted #5547

luetage opened this issue Jan 15, 2023 · 21 comments
Labels
C-bug Category: This is a bug upstream

Comments

@luetage
Copy link
Contributor

luetage commented Jan 15, 2023

Summary

I installed vscode-langservers-extracted locally through npm. No diagnostics are shown for html/json/css. Installing globally doesn’t make a difference. Helix editor is installed from source and the runtime is linked. Rust and typescript language servers work fine. The vscode-langservers-extracted binaries work fine in neovim, I doubt it’s the installation, maybe I did something wrong in the implementation, but I don’t know what that could be. I cleared my languages.toml file one time to test without, same result and log messages. I tried with different CSS and HTML files, within and outside of git repos. Happy for any pointers how I could test this more thoroughly from my end.

Reproduction Steps

I tried this: Open CSS file in editor, delete a closing bracket.

I expected this to happen: Diagnostics visible in gutter/statusline/diagnostic picker

Instead, this happened: No diagnostics are shown anywhere, despite CSS language server being connected

Helix log

~/.cache/helix/helix.log
2023-01-15T22:43:38.917 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":1,"message":"Error while validating file:///home/user/projects/vivaldi_modding/load/addressfield-theming.css: Cannot read properties of null (reading 'validProperties')\nTypeError: Cannot read properties of null (reading 'validProperties')\n    at LintConfigurationSettings.getSetting (/home/user/.npm/node_modules/vscode-css-languageservice/lib/umd/services/lintRules.js:78:29)\n    at new LintVisitor (/home/user/.npm/node_modules/vscode-css-languageservice/lib/umd/services/lint.js:53:41)\n    at LintVisitor.entries (/home/user/.npm/node_modules/vscode-css-languageservice/lib/umd/services/lint.js:41:29)\n    at CSSValidation.doValidation (/home/user/.npm/node_modules/vscode-css-languageservice/lib/umd/services/cssValidation.js:34:60)\n    at _callee15$ (/home/user/.npm/node_modules/vscode-langservers-extracted/lib/css-language-server/cssServer.js:288:83)\n    at tryCatch (/home/user/.npm/node_modules/regenerator-runtime/runtime.js:64:40)\n    at Generator.invoke (/home/user/.npm/node_modules/regenerator-runtime/runtime.js:299:22)\n    at Generator.next (/home/user/.npm/node_modules/regenerator-runtime/runtime.js:124:21)\n    at asyncGeneratorStep (/home/user/.npm/node_modules/vscode-langservers-extracted/lib/css-language-server/cssServer.js:53:103)\n    at _next (/home/user/.npm/node_modules/vscode-langservers-extracted/lib/css-language-server/cssServer.js:55:194)"}}
2023-01-15T22:43:38.917 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Error, message: "Error while validating file:///home/user/projects/vivaldi_modding/load/addressfield-theming.css: Cannot read properties of null (reading 'validProperties')\nTypeError: Cannot read properties of null (reading 'validProperties')\n    at LintConfigurationSettings.getSetting (/home/user/.npm/node_modules/vscode-css-languageservice/lib/umd/services/lintRules.js:78:29)\n    at new LintVisitor (/home/user/.npm/node_modules/vscode-css-languageservice/lib/umd/services/lint.js:53:41)\n    at LintVisitor.entries (/home/user/.npm/node_modules/vscode-css-languageservice/lib/umd/services/lint.js:41:29)\n    at CSSValidation.doValidation (/home/user/.npm/node_modules/vscode-css-languageservice/lib/umd/services/cssValidation.js:34:60)\n    at _callee15$ (/home/user/.npm/node_modules/vscode-langservers-extracted/lib/css-language-server/cssServer.js:288:83)\n    at tryCatch (/home/user/.npm/node_modules/regenerator-runtime/runtime.js:64:40)\n    at Generator.invoke (/home/user/.npm/node_modules/regenerator-runtime/runtime.js:299:22)\n    at Generator.next (/home/user/.npm/node_modules/regenerator-runtime/runtime.js:124:21)\n    at asyncGeneratorStep (/home/user/.npm/node_modules/vscode-langservers-extracted/lib/css-language-server/cssServer.js:53:103)\n    at _next (/home/user/.npm/node_modules/vscode-langservers-extracted/lib/css-language-server/cssServer.js:55:194)" }

Platform

Linux

Terminal Emulator

alacritty 0.10.1

Helix Version

22.12-125-gb6331394

@luetage luetage added the C-bug Category: This is a bug label Jan 15, 2023
@archseer
Copy link
Member

@archseer
Copy link
Member

The log you provided seems to have an error on the language server side

@luetage
Copy link
Contributor Author

luetage commented Jan 16, 2023

Thanks for taking a look. I’ve seen the troubleshooting steps, here are the results for the health check:

Configured language server: vscode-html-language-server
Binary for language server: /home/user/.npm/node_modules/.bin/vscode-html-language-server
Configured debug adapter: None
Highlight queries: ✓
Textobject queries: ✘
Indent queries: ✘

Configured language server: vscode-json-language-server
Binary for language server: /home/user/.npm/node_modules/.bin/vscode-json-language-server
Configured debug adapter: None
Highlight queries: ✓
Textobject queries: ✘
Indent queries: ✓

Configured language server: vscode-css-language-server
Binary for language server: /home/user/.npm/node_modules/.bin/vscode-css-language-server
Configured debug adapter: None
Highlight queries: ✓
Textobject queries: ✘
Indent queries: ✘

/home/user/.npm/node_modules/.bin is in the $PATH. Not quite sure what else I could try.

@David-Else
Copy link
Contributor

David-Else commented Jan 18, 2023

I have installed vscode-css-language-server globally on Linux using sudo npm install -g vscode-langservers-extracted and the result is:

hx --health css
Configured language server: vscode-css-language-server
Binary for language server: /usr/local/bin/vscode-css-language-server
Configured debug adapter: None
Highlight queries: ✓
Textobject queries: ✘
Indent queries: ✘

I don't think you have them installed globally 'properly', delete everything you have and try again, note mine are not in my home directory but /usr/local/bin/...

What do you get with npm ls -g? I have:

$ npm ls -g
/usr/local/lib
└── vscode-langservers-extracted@4.5.0

In the terminal you should be able to type vscode-css-language-server and get some garbage output to verify it is actually in the $PATH.

@luetage
Copy link
Contributor Author

luetage commented Jan 18, 2023

Thanks for taking a look. Yes, the executables are in the $PATH and I get output. And I already uninstalled the langservers-extracted locally and reinstalled them globally, with the exact same result. Archseer is right, the language server itself throws errors pointing to its own files. Which doesn’t make much sense, because I have installed them several times from the same source as everybody else. And I had the same servers installed before for Neovim and they worked. But then again we already ruled out Helix as the problem because error points to the server. None of this makes any sense.

Anyway, I just now removed the path to the local servers from .bashrc, restarted terminal and installed langservers globally again, with the same result, no diagnostic, no autocompletion, same errors, but language servers connected.

outputs:

> ~@ npm ls -g
/usr/local/lib
├── npm@8.12.1
└── vscode-langservers-extracted@4.5.0
> .npm@ npm ls -i
.npm@ /home/user/.npm
├── prettier@2.8.3
├── typescript-language-server@3.0.2
├── typescript@4.9.4
└── vscode-langservers-extracted@4.5.0

@David-Else
Copy link
Contributor

David-Else commented Jan 18, 2023

Cannot read properties of null, do you have an outdated Node version, or maybe even NPM? It looks like your JS is not running properly, so I would say it points to your NodeJS. I have node v16.17.1 on AlmaLinux 9.1.

@luetage
Copy link
Contributor Author

luetage commented Jan 18, 2023

Hmm, you could be on to something. I’m on Fedora 37 and my node version is 18.12.1. Maybe it’s too new.

@David-Else
Copy link
Contributor

It could be it! You might be able to use an older version with dnf module install, I tried https://github.com/nvm-sh/nvm years ago, but I think it never worked and I wasted hours... but some people swear by it.

@luetage
Copy link
Contributor Author

luetage commented Jan 18, 2023

Thanks, nvm works like a charm in my case. Installed and used the 16 version of nodejs, but exact same errors. Seems like node is not the culprit.

@David-Else
Copy link
Contributor

You could try asking for help at https://github.com/hrsh7th/vscode-langservers-extracted , it seems the maintainer has modified things slightly from the vanilla VS Code install, so maybe he could shed some light on it.

@hrsh7th
Copy link

hrsh7th commented Feb 6, 2023

Found this thread today.

This may be a bug in vscode-langservers-extracted.
However, if it is a bug, it can be difficult to fix while maintaining the current configuration.

It could be a separate package such as vscode-html-langserver-extracted. (not yet at the moment).

@hrsh7th
Copy link

hrsh7th commented Feb 6, 2023

I found the cause, You should send workspace/configuration to vscode-json-language-server.

https://github.com/microsoft/vscode/blob/main/extensions/json-language-features/package.json#L77

@luetage
Copy link
Contributor Author

luetage commented Feb 6, 2023

@hrsh7th Thank you. So after reading this I added config = { json.validate.enable = true } to my languages.toml file, afterwards diagnostics for JSON are working. But I don’t understand why this is needed, because it is supposed to be a default. I’m also not sure how to fix HTML and CSS. package.json for CSS language features has a css.validate key for example, but setting it to true does nothing. And I’m still not sure why I appear to be the only one with issues. I’m simply out of my depth here.

@David-Else
Copy link
Contributor

@luetage You are not the only one with the issue, but maybe nobody is reporting it.

I tried:

[[language]]
name = "json"
config = { json.validate.enable = true, json.format.enable = true }

The validation works, but the formatting does not seem to enable?

@the-mikedavis Do you have any idea why the defaults are not being read? I would like to submit a pull request to fix this, but need a little more insight into what is happening.

@the-mikedavis
Copy link
Member

I can reproduce this: that the true value for json.validate.enable needs to be manually set. I'm not sure why it's necessary to set this manually though. We send the config (for example {"provideFormatter": true} by default) in the initialize request within the initializationOptions as well as a follow-up workspace/didChangeConfiguration notification after initialization (we send this to emulate nvim's behavior). The server doesn't send us a workspace/configuration request as far as I can see. I'm testing with vscode-json-language-server 4.6.0.

If this works without needing to be manually set in another editor and someone could post a log of the client/server communication for that editor, that would help debug this.

@David-Else
Copy link
Contributor

I looked at nvim, and it also only provided:

https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/jsonls.lua#L14

    init_options = {
      provideFormatter = true,
    },

and it ALSO does not validate JSON. Maybe nobody is noticing as Treesitter highlights errors in red and people assume it is the language server doing it?

@hrsh7th The JSON language server is not respecting the defaults shown at https://github.com/microsoft/vscode/blob/main/extensions/json-language-features/package.json#L77 , can you fix this at your end, or shall we just add json.validate.enable = true here... but then why does json.format.enable = true not work?

@the-mikedavis
Copy link
Member

I'm not sure what json.format.enable actually does - setting it doesn't seem to have an effect. provideFormatter needs to be set to true though: that sets documentFormattingProvider to true in the server capabilities message. If you are only setting

config = { json.validate.enable = true, json.format.enable = true }

that will not be merged on top of the provideFormatter value so you will need to add that to the config as well:

[[language]]
name = "json"
[language.config]
provideFormatter = true
json.validate.enable = true
json.format.enable = true

I think that the json.validate.enable part of this will need to be debugged in the vscode codebase. If I understand correctly, your extracted repo is about packaging the language servers separately from vscode rather than a fork of those servers @hrsh7th?

@hrsh7th
Copy link

hrsh7th commented Feb 16, 2023

Perhaps it's related to this commit?

However, we are in a position to use the implementation, and we think that there is no problem on the json-language-features side.

According to my research, the current default value for json.validate.enable in json-language-server is actually true.

But it seems to be false if send workspace/didChangeConfiguration notification with payload that omitted json.validate.enable.

@hrsh7th
Copy link

hrsh7th commented Feb 16, 2023

Also, I'm not going to do my own patching with vscode-langservers-extracted, so I'll have to either do an upstream PR or do something on the editor side.

@the-mikedavis
Copy link
Member

But it seems to be false if send workspace/didChangeConfiguration notification with payload that omitted json.validate.enable.

Ah I see, I can confirm this. If I comment out this block then I see validation diagnostics with no extra config:

// Trigger a workspace/didChangeConfiguration notification after initialization.
// This might not be required by the spec but Neovim does this as well, so it's
// probably a good idea for compatibility.
if let Some(config) = language_server.config() {
tokio::spawn(language_server.did_change_configuration(config.clone()));
}

That explains why this behavior happens in nvim too since nvim also sends the didChangeConfiguration after initialization.

I think this should be fixed upstream in the vscode codebase. IMO the current behavior is confusing and it would be ideal for the defaults to be the same between initializationOptions and didChangeConfiguration.

Thank you for your help debugging, @hrsh7th!

@David-Else
Copy link
Contributor

@the-mikedavis I think this can be closed with #8433 now being merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug upstream
Projects
None yet
Development

No branches or pull requests

6 participants