microsoft / language-server-protocol

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

Server to client TextDocumentItem/ #1458

Open ratmice opened 2 years ago

ratmice commented 2 years ago

I was curious if there were any plans for a server to client mechanism for sending TextDocumentItem's from server to client, currently which I understand is only used for sending client documents to the server.

As well as a mechanism for specifying a uri for each active lsp presumably the uri could be sent to the client in the serverInfo of a InitializeResult from which a client can then recognize documents from the server inside TextDocumentIdentifiers. And a new request by which clients could retrieve a server document.

The LSP that I am working generates some extremely long diagnostics, unfortunately diagnostics are typically displayed by editors in a fashion which is only suitable for extremely short messages. In these cases of excessively long diagnostics, it would be nice if we could then refer to server generated documents via their URL in via the relatedDocuments component of the diagnostic.

rwols commented 2 years ago

The LSP that I am working generates some extremely long diagnostics, unfortunately diagnostics are typically displayed by editors in a fashion which is only suitable for extremely short messages.

Have you considered shortening the messages, and then referring to "more in-depth" via CodeDescription?

ratmice commented 2 years ago

The LSP that I am working generates some extremely long diagnostics, unfortunately diagnostics are typically displayed by editors in a fashion which is only suitable for extremely short messages.

Have you considered shortening the messages, and then referring to "more in-depth" via CodeDescription?

It not static text, but entirely generated with information derived from the source text. If you are familiar with parsers, yacc and the like it essentially contains a representation of the parsing stack which arises from a conflict in the grammar (where my lsp is dealing with yacc files.).

RobbyCBennett commented 1 year ago

The rust-analyzer extension has a workaround for dynamically-generated codeDescription fields. In these parts of their code they create a TextDocumentContentProvider.

However, this is a fix for just VS Code and rust-analyzer, so it's not an ideal solution for the LSP as a whole.

ratmice commented 1 year ago

@RobbyCBennett Yeah, implementing a TextDocumentContentProvider is exactly what I ended up doing as well eventually.

ratmice commented 1 year ago

@RobbyCBennett I believe your second comment was actually intended for #1461

RobbyCBennett commented 1 year ago

Okay. I'll move it to there.