Add auto-cleanup to eglot documentation buffer

This commit is contained in:
Alexander Rosenberg 2024-09-28 04:22:14 -07:00
parent 69e77a7449
commit 7c2cb2f54d
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730

12
init.el
View File

@ -680,6 +680,18 @@ to `posframe-show' if the display is graphical."
(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-cleanup-doc-buffer (_server &optional _interactive _timeout
preserve-buffers)
(when (and (not preserve-buffers)
(buffer-live-p my/-eglot-documentation-buffer)
(cl-every (lambda (buffer)
(with-current-buffer buffer
(let ((server (eglot-current-server)))
(or (not (eglot-lsp-server-p server))
(eglot--shutdown-requested server)))))
(buffer-list)))
(kill-buffer my/-eglot-documentation-buffer)))
(advice-add 'eglot-shutdown :after 'my/-eglot-cleanup-doc-buffer)
(defun my/-eglot-setup ()
"Setup eldoc variables for `eglot-managed-mode-hook'."
(setq-local evil-lookup-func #'my/eglot-documentation-at-point)