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

**URL:** https://discuss.codemirror.net/t/return-promise-tooltip-from-hovertooltips-source-function/2967
**Category:** v6
**Created:** [February 27, 2021, 6:56am UTC](https://discuss.codemirror.net/t/return-promise-tooltip-from-hovertooltips-source-function/2967 "2021-02-27T06:56:10Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![hjr265](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/hjr265/32/1092_2.png) [@hjr265](https://discuss.codemirror.net/u/hjr265)
#### Post date: [February 27, 2021, 6:56am UTC](https://discuss.codemirror.net/t/return-promise-tooltip-from-hovertooltips-source-function/2967/1 "2021-02-27T06:56:10Z")

</div>

It seems the `source` argument in [`hoverTooltip`](https://codemirror.net/6/docs/ref/#tooltip.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](https://github.com/FurqanSoftware/codemirror-languageserver/blob/master/index.coffee#L173) from the `source` function. And, then [showed a tooltip](https://github.com/FurqanSoftware/codemirror-languageserver/blob/master/index.coffee#L162) once a response from the Language Server is received.

And in that same plugin, I was able to use [`linter`](https://codemirror.net/6/docs/ref/#lint.linter) and [`autocompletion`](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion) without the same level of _hacky_ code.

---

<div class="post-metadata">

### Author: ![marijn](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/marijn/32/136_2.png) [@marijn](https://discuss.codemirror.net/u/marijn)
#### Post date: [March 4, 2021, 10:50am UTC](https://discuss.codemirror.net/t/return-promise-tooltip-from-hovertooltips-source-function/2967/2 "2021-03-04T10:50:25Z")

</div>

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

---

<div class="post-metadata">

### Author: ![hjr265](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/hjr265/32/1092_2.png) [@hjr265](https://discuss.codemirror.net/u/hjr265)
#### Post date: [March 5, 2021, 3:34am UTC](https://discuss.codemirror.net/t/return-promise-tooltip-from-hovertooltips-source-function/2967/3 "2021-03-05T03:34:25Z")

</div>

Thank you! That makes my implementation so much better: [Reduce workaround code, leverage new hoverTooltip API · FurqanSoftware/codemirror-languageserver@00f6686 · GitHub](https://github.com/FurqanSoftware/codemirror-languageserver/commit/00f6686e6322f541c28d49abbe6ff02b2dd3cdb4)

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