From c198ea9931e102410965583de6317ddbf56581db Mon Sep 17 00:00:00 2001 From: rbrtb Date: Sun, 1 May 2022 03:34:47 +0800 Subject: [PATCH] Refactor eglot--managed-mode enabling Fixes https://github.com/joaotavora/eglot/issues/824 --- eglot.el | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/eglot.el b/eglot.el index 3d1b19c9..b858c306 100644 --- a/eglot.el +++ b/eglot.el @@ -1047,8 +1047,9 @@ INTERACTIVE is t if called interactively." () (remove-hook 'post-command-hook #'maybe-connect nil) (eglot--when-live-buffer buffer - (unless eglot--managed-mode - (apply #'eglot--connect (eglot--guess-contact)))))) + (unless (eglot-current-server) + (apply #'eglot--connect (eglot--guess-contact))) + (eglot--maybe-activate-editing-mode)))) (when buffer-file-name (add-hook 'post-command-hook #'maybe-connect 'append nil))))) @@ -1723,9 +1724,6 @@ If it is activated, also signal textDocument/didOpen." (eglot--managed-mode) (eglot--signal-textDocument/didOpen)))) -(add-hook 'find-file-hook 'eglot--maybe-activate-editing-mode) -(add-hook 'after-change-major-mode-hook 'eglot--maybe-activate-editing-mode) - (defun eglot-clear-status (server) "Clear the last JSONRPC error for SERVER." (interactive (list (eglot--current-server-or-lose)))