add multiple line doc support for eglot

This commit is contained in:
zedhugh committed 2023-10-09 18:07:29 +08:00
1 parent 7933cfb49c
commit 2f3efabd0e
1 file changed
+25
+25
View File
@@ -9,6 +9,26 @@
(locate-library "markdown-mode"))
(require 'markdown-mode)))
(defun creature/eglot-hover-eldoc-function (cb)
"Multiple line version of `eglot-hover-eldoc-function'."
(let ((eglot-server-capable-fn
(if (fboundp 'eglot-server-capable)
'eglot-server-capable
'eglot--server-capable)))
(when (funcall eglot-server-capable-fn :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))))
(funcall cb info :buffer t))))
:deferred :textDocument/hover))
(eglot--highlight-piggyback cb)
t)))
(with-eval-after-load 'eglot
(setq eglot-events-buffer-size 0)
(setq eglot-confirm-server-initiated-edits nil)
@@ -17,6 +37,11 @@
(add-hook 'eglot-managed-mode-hook #'creature/eglot-load-markdown-for-doc)
;; variable `eglot-prefer-plaintext' invoked in eglot-1.14
;; and document only show one line by eldoc since eglot-1.14
(when (boundp 'eglot-prefer-plaintext)
(advice-add 'eglot-hover-eldoc-function :override #'creature/eglot-hover-eldoc-function))
(lazy-load-set-keys
'(("M-." . xref-find-definitions)
("M-?" . xref-find-references)