Skip to content

Commit 2b8f29f

Browse files
authored
Display the first line of MarkupContent in eldoc (#1607)
* Display the first line of MarkupContent in eldoc Many LSP servers, like gopls, return `document/onHover` as MarkupContent. This modifies the eldoc behavior to support MarkupContent by displaying the first rendered line. As the majority of LSP servers return the signature, this will display the signature as most people expect. In the future, microsoft/language-server-protocol#772 should make this more reliable. * nit: use s-lines
1 parent d89f403 commit 2b8f29f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lsp-mode.el

+5-3
Original file line numberDiff line numberDiff line change
@@ -4715,9 +4715,11 @@ CONTENTS - MarkedString | MarkedString[] | MarkupContent
47154715
RENDER-ALL - nil if only the signature should be rendered."
47164716
(cond
47174717
((and (hash-table-p contents) (gethash "kind" contents))
4718-
;; MarkupContent, deprecated by LSP but actually very flexible.
4719-
;; It tends to be long and is not suitable in echo area.
4720-
(if render-all (lsp--render-element contents) ""))
4718+
;; MarkupContent.
4719+
;; It tends to be long and is not suitable to display fully in the echo area.
4720+
;; Just display the first line which is typically the signature.
4721+
(let ((rendered (lsp--render-element contents)))
4722+
(if render-all rendered (car (s-lines rendered)))))
47214723
((and (stringp contents) (not (string-match-p "\n" contents)))
47224724
;; If the contents is a single string containing a single line,
47234725
;; render it always.

0 commit comments

Comments
 (0)