Skip to content

Commit c2f5636

Browse files
committed
Update pyls hover to specify language of signature.
LSP supports `MarkedString[]` to specify render engine. We can definitely say that function signature should be rendered as python. For the docstring, as we have no good way of parsing it to guess the engine, we can pass it as markdown.
1 parent 363e39a commit c2f5636

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

pyls/plugins/hover.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ def pyls_hover(document, position):
1313
# Find an exact match for a completion
1414
for d in definitions:
1515
if d.name == word:
16-
return {'contents': _utils.format_docstring(d.docstring()) or ''}
16+
doc = _utils.format_docstring(d.docstring()).split("\n", 1)
17+
if not doc:
18+
return {'contents': ''}
19+
contents = [{
20+
"language": "python",
21+
"value": doc[0],
22+
}]
23+
if len(doc) > 1:
24+
contents.append(doc[1])
25+
return {'contents': contents}
1726

1827
return {'contents': ''}

0 commit comments

Comments
 (0)