eclipselabs/eclipse-language-service

support markdown in hovers

Closed this issue · 7 comments

VS Code supports markdown in hovers, the generic editor displays the plain content of the hover as text, not rendering markdown.

In addition to that I would love to discuss if it would make sense to also support HTML hovers (as this is the case in old-style Eclipse hovers), so that the language server could return the hover information as markdown AND HTML, and in case HTML is delivered, the Eclipse editor could use that (instead of rendering the markdown).

See https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#hover-request . The behaviour is specified: by default, it's markdown, unless returned differently.
Note that ideally, hovering would allow to get responses from several LS, and then from different formats simultaneously.

But how can I return both, Markdown and HTML, so that the client can choose which one to render? And how can I specify that I return HTML? As the language type value?

@mickaelistria I am not sure if you read the spec correctly. The hover text is always returned in the markdown format and there is no alternative (for now).

The case where the language property is specified is a markdown code block, so you have syntax highlighting for code, e.g. to have HTML code displayed like this:

<p>some <i>highlighted</i> html code</p>

not like this:

some highlighted html code

But how can I return both, Markdown and HTML, so that the client can choose which one to render? And how can I specify that I return HTML? As the language type value?

You can't. What you can do is, on server side, capture the InitializationParams when initiating the connection and look at the value of the product. This is a bit like a user-agent for HTTP, so you can modify the response of the server according to it.
Currently, the product in LSP4E is set to the application name, but I imagine it should also say "Eclipse LSP4E - " to be more reliable to take decisions on server side.

I am not sure if you read the spec correctly. The hover text is always returned in the markdown format and there is no alternative (for now).

Ah ok, I misunderstood this. Then, @martinlippert , no need to work on specific HTML return. This is not in the scope of the protocol, and LSP4E (or other Eclipse layer) will have to provide Markdown rendering in Hover.

And, BTW, the Markdown syntax supports inline HTML. So, if you have a language server returning HTML for hovers, this should be fine for clients that could render Markdown.

Yeah, we are probably fine with good markdown support (instead of additional HTML)... :-)