eglot only displays the first line of the doc string provided by LSP server #1467
-
After upgrading eglot from 1.12 to 1.17, the doc string in echo area is incomplete for For example, when hoverring on a variant of Definition of #[derive(Debug)]
pub enum RustAnalyzerCmd {
LspServer(LspServer),
Parse(Parse),
Symbols(Symbols),
Highlight(Highlight),
AnalysisStats(AnalysisStats),
RunTests(RunTests),
RustcTests(RustcTests),
Diagnostics(Diagnostics),
UnresolvedReferences(UnresolvedReferences),
Ssr(Ssr),
Search(Search),
Lsif(Lsif),
Scip(Scip),
}
I first checked if rust-analyzer responds with incomplete info. Turns out rust-analyzer is innocent.
So I figured it could be either After glimpsing through the eldoc package, especially functions like The interesting part is This is the modified version of (defun eglot-hover-eldoc-function (cb)
"A member of `eldoc-documentation-functions', for hover."
(when (eglot-server-capable :hoverProvider)
(let ((buf (current-buffer)))
(jsonrpc-async-request
(eglot--current-server-or-lose)
:textDocument/hover (eglot--TextDocumentPositionParams)
:success-fn (eglot--lambda ((Hover) contents range)
(eglot--when-buffer-window buf
(let ((info (unless (seq-empty-p contents)
(eglot--hover-info contents range))))
(message "Check info: %s" info) ; <--- Added logging.
(funcall cb info
:echo (and info (string-match "\n" info))))))
:deferred :textDocument/hover))
(eglot--highlight-piggyback cb)
t)) After replacing Now I am curious why the choice is made to only display the doc string until the first newline? Finally, many thanks for your great package! I use it everyday, and I mean to study it to get more familiar with the LSP protocol, and maybe contribute to eglot someday :). |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
The echo area is a hotly contested small space. Maybe eldoc documentation functions live there, and eldoc will ask for the "oneliner" |
Beta Was this translation helpful? Give feedback.
-
You should use something like this (taken from that discussion): (defun my/special-eglot-hover-function (cb)
"Same as `eglot-hover-eldoc-function`, but throw away its short :echo cookie"
(eglot-hover-eldoc-function (lambda (info &rest _ignore)
;; ignore the :echo cookie that eglot-hover-eldoc-function offers
(funcall cb info))))
(add-hook
'eglot-managed-mode-hook
(lambda ()
(setq-local eldoc-documentation-functions
(cl-substitute #'my/special-eglot-hover-function
'eglot-hover-eldoc-function
eldoc-documentation-functions))) |
Beta Was this translation helpful? Give feedback.
-
Of course, remove your customization of |
Beta Was this translation helpful? Give feedback.
-
Thanks for your quick reply. I tried your suggesion and it works and is much cleaner than redefining the function. |
Beta Was this translation helpful? Give feedback.
You should use something like this (taken from that discussion):