Add better eglot doc function
This commit is contained in:
parent
aba461a801
commit
5f1ac858a2
28
init.el
28
init.el
@ -391,10 +391,34 @@ visual states."
|
||||
python-ts-mode latex-mode) . eglot-ensure)
|
||||
(eglot-managed-mode . my/-eglot-setup))
|
||||
:init
|
||||
(defvar my/-eglot-documentation-buffer nil
|
||||
"Buffer for showing documentation for `my/eglot-documentation-at-point'.")
|
||||
(defun my/eglot-documentation-at-point ()
|
||||
"Show documentation for a symbol at point."
|
||||
(interactive)
|
||||
(if-let (server (eglot-current-server))
|
||||
(progn
|
||||
(if-let* (((not (buffer-live-p my/-eglot-documentation-buffer)))
|
||||
(name (generate-new-buffer-name "*eglot documentation*")))
|
||||
(setq my/-eglot-documentation-buffer (generate-new-buffer name)))
|
||||
(eglot-hover-eldoc-function
|
||||
(lambda (info _ _)
|
||||
(if-let (((not (seq-empty-p info)))
|
||||
(buff (current-buffer)))
|
||||
(with-current-buffer my/-eglot-documentation-buffer
|
||||
(read-only-mode -1)
|
||||
(erase-buffer)
|
||||
(insert info)
|
||||
(special-mode)
|
||||
(read-only-mode 1)
|
||||
(when (not (get-buffer-window my/-eglot-documentation-buffer nil))
|
||||
(switch-to-buffer-other-window my/-eglot-documentation-buffer t)
|
||||
(switch-to-buffer-other-window buff t)))))))))
|
||||
(defun my/-eglot-setup ()
|
||||
"Setup eldoc variables for `eglot-managed-mode-hook'."
|
||||
(setq-local eldoc-echo-area-use-multiline-p
|
||||
nil)
|
||||
(setq-local eldoc-echo-area-use-multiline-p nil
|
||||
evil-lookup-func #'my/eglot-documentation-at-point)
|
||||
(evil-define-key '(normal motion) 'local "K" #'evil-lookup)
|
||||
(eglot-inlay-hints-mode -1))
|
||||
(advice-add 'eglot-completion-at-point :around #'cape-wrap-buster)
|
||||
(setq eglot-autoshutdown t))
|
||||
|
Loading…
Reference in New Issue
Block a user