tools/lsp: defer auto-shutdown of eglot server
This commit is contained in:
parent
f454d5fac4
commit
06c6946742
1 changed files with 19 additions and 2 deletions
|
@ -1,7 +1,6 @@
|
||||||
;;; tools/lsp/+eglot.el -*- lexical-binding: t; -*-
|
;;; tools/lsp/+eglot.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
;; TODO set eglot-events-buffer-size to nil in doom-debug-mode
|
;; TODO set eglot-events-buffer-size to nil in doom-debug-mode
|
||||||
;; TODO Implement `+lsp-defer-shutdown'
|
|
||||||
|
|
||||||
(use-package! eglot
|
(use-package! eglot
|
||||||
:commands eglot eglot-ensure
|
:commands eglot eglot-ensure
|
||||||
|
@ -23,4 +22,22 @@
|
||||||
:documentation #'+eglot-lookup-documentation)
|
:documentation #'+eglot-lookup-documentation)
|
||||||
(when (featurep! :checkers syntax)
|
(when (featurep! :checkers syntax)
|
||||||
(after! flycheck
|
(after! flycheck
|
||||||
(load! "autoload/flycheck-eglot"))))
|
(load! "autoload/flycheck-eglot")))
|
||||||
|
|
||||||
|
(defadvice! +lsp--defer-server-shutdown-a (orig-fn &optional server)
|
||||||
|
"Defer server shutdown for a few seconds.
|
||||||
|
This gives the user a chance to open other project files before the server is
|
||||||
|
auto-killed (which is a potentially expensive process). It also prevents the
|
||||||
|
server getting expensively restarted when reverting buffers."
|
||||||
|
:around #'eglot--managed-mode
|
||||||
|
(letf! (defun eglot-shutdown (server)
|
||||||
|
(if (or (null +lsp-defer-shutdown)
|
||||||
|
(eq +lsp-defer-shutdown 0))
|
||||||
|
(funcall eglot-shutdown server)
|
||||||
|
(run-at-time
|
||||||
|
(if (numberp +lsp-defer-shutdown) +lsp-defer-shutdown 3)
|
||||||
|
nil (lambda (server)
|
||||||
|
(unless (eglot--managed-buffers server)
|
||||||
|
(funcall eglot-shutdown server)))
|
||||||
|
server)))
|
||||||
|
(funcall orig-fn server))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue