Skip to content

Commit

Permalink
Implement autoshutdown when killing last buffer (#305)
Browse files Browse the repository at this point in the history
This should close issue #217, also cf. #270.

* eglot.el: New defcustom `eglot-autoshutdown' (default nil).
(eglot--managed-mode-onoff): Shutdown if so configured and no managed
buffers left.
  • Loading branch information
ingolohmar authored and Ingo Lohmar committed Sep 24, 2019
1 parent 7f31f29 commit b2a174e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion eglot.el
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ as 0, i.e. don't block at all."
:type '(choice (boolean :tag "Whether to inhibit autoreconnection")
(integer :tag "Number of seconds")))

(defcustom eglot-autoshutdown nil
"If t, shut down a language server automatically after killing
the last buffer it has managed."
:type 'boolean)

(defcustom eglot-events-buffer-size 2000000
"Control the size of the Eglot events buffer.
If a number, don't let the buffer grow larger than that many
Expand Down Expand Up @@ -1220,7 +1225,11 @@ Reset in `eglot--managed-mode-onoff'.")
(setq eglot--cached-current-server nil)
(when server
(setf (eglot--managed-buffers server)
(delq buf (eglot--managed-buffers server)))))))))
(delq buf (eglot--managed-buffers server)))
(when (and eglot-autoshutdown
(not (eglot--shutdown-requested server))
(not (eglot--managed-buffers server)))
(eglot-shutdown server))))))))

(defun eglot--current-server ()
"Find the current logical EGLOT server."
Expand Down

0 comments on commit b2a174e

Please sign in to comment.