Return Promise<Tooltip> from hoverTooltip's source function?

It seems the source argument in hoverTooltip, when called, is expected to return Tooltip | null.

This works fine when the contents and precise position of the Tooltip is known immediately. However, when trying to fetch the documentation of the hovered symbol from a Language Server, it requires a round trip.

Would it be too much work to also allow a return of Promise<Tooltip> from this source function? I hope I didn’t miss something obvious and am asking for something that is not even necessary to achieve this goal.

In my rudimentary implementation of a Language Server integration plugin, I have resorted to always returning null from the source function. And, then showed a tooltip once a response from the Language Server is received.

And in that same plugin, I was able to use linter and autocompletion without the same level of hacky code.

That’s a good idea. @codemirror/tooltip 0.18.1 supports this.

1 Like

Thank you! That makes my implementation so much better: Reduce workaround code, leverage new hoverTooltip API · FurqanSoftware/codemirror-languageserver@00f6686 · GitHub

I was also able to remove some workaround code to hide the tooltip on key/mouse activity.