microsoft / language-server-protocol

Defines a common protocol for language servers.
https://microsoft.github.io/language-server-protocol/
Creative Commons Attribution 4.0 International
10.9k stars 760 forks source link

The meaning of a missing diagnostic severity is ambiguous #1958

Open remcohaszing opened 1 week ago

remcohaszing commented 1 week ago

The LSP specification for diagnostics specifies:

The diagnostic's severity. Can be omitted. If omitted it is up to the client to interpret diagnostics as error, warning, info or hint.

I find this a bit odd to be honest. Why would anyone want a diagnostic to be an error in one client, but a hint in another? I noticed this is interpreted differently even within the VSCode ecosystem. In vscode-languageclient, the severity defaults to Error. In Monaco editor however, it defaults to Info.

In my own package monaco-languageserver-types I made the default configurable, with a default to Error. This feels weird though. Why would anyone deviate from Monaco editor? On the other hand, why would anyone deviate from VSCode?

I suggest to:

  1. Align Monaco editor and vscode-languageclient.
  2. Recommended a default severity to use in the specification.
rcjsuen commented 1 week ago

Recommended a default severity to use in the specification.

This makes sense to me. I suggest you raise an issue about this in microsoft/language-server-protocol.

dbaeumer commented 1 week ago

We can add a recommendation however enforcing it would be a breaking change. What we could do is to add the default severity used by the client to the initialize request so that servers at least know what the value is.

dbaeumer commented 1 week ago

I will transfer the issue since the work as to start in the lsp repository.

remcohaszing commented 1 week ago

I agree enforcing it would be a breaking change and we should stick with recommendations. I have my doubts about the usefulness of communicating the default severity used by the client in the initialize request though. What would the server use it for? Instead, I think it would be better to strongly recommend servers to always specify the severity explicitly.

Also what would the recommended default be? I’m leaning towards Error, as vscode-languageclient is used to integrate a lot of language servers already. Meanwhile the Monaco editor implementation is only used to integrate language services that are owned by Microsoft. I don’t know what other clients do.