If the language server returns the right type of hover contents, Nova can syntax highlight code in the tooltip:
https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#hover
There are a few ways to do it, either by making sure the content string is markdown with fenced code blocks annotated with the syntax, or like this…
LSP request:
{
"jsonrpc": "2.0",
"id": 442,
"method": "textDocument\\/hover",
"params": {
"textDocument": {
"uri": "file:\\/\\/[redacted]\\/foo.ts"
},
"position": {
"line": 1,
"character": 9
}
}
}
LSP response:
{
"jsonrpc": "2.0",
"id": 442,
"result": {
"contents": [
{
"language": "typescript",
"value": "function foo(): void"
},
"Description."
],
"range": {
"start": {
"line": 1,
"character": 9
},
"end": {
"line": 1,
"character": 12
}
}
}
}
Note that the Description.
text isn’t displaying in the hover tooltip due to a Nova bug, see: