When manually changing the major-mode of a managed buffer, this sends
a didClose and tears down Eglot-related stuff like if were killing the
buffer. After changing the mode, we have to recheck that we are now
not managed by another server (or by the same server, in case we
changed the mode to be the same mode).
* eglot.el (eglot-shutdown): Use eglot--with-live-buffer
(eglot--on-shutdown): Use eglot--with-live-buffer
(eglot--managed-mode): Use change-major-mode-hook.
(eglot--managed-mode-onoff): Change protocol. Turn off when called
with no arguments.
(eglot--maybe-activate-editing-mode): Don't do anything if mode is
already active. Suitable for calling from
after-change-major-mode-hook.
(after-change-major-mode-hook): Add
eglot--maybe-activate-editing-mode.
GitHub-reference: close https://github.com/joaotavora/eglot/issues/44