(add-hook 'eglot--managed-mode-hook 'flymake-mode)
(add-hook 'eglot--managed-mode-hook 'eldoc-mode)
+(defun eglot--find-current-server ()
+ "Find the current logical EGLOT server."
+ (let* ((probe (or (project-current) `(transient . ,default-directory))))
+ (cl-find major-mode (gethash probe eglot--servers-by-project)
+ :key #'eglot--major-mode)))
+
+ (defvar-local eglot--unreported-diagnostics nil
+ "Unreported Flymake diagnostics for this buffer.")
+
(defun eglot--maybe-activate-editing-mode (&optional server)
"Maybe activate mode function `eglot--managed-mode'.
If SERVER is supplied, do it only if BUFFER is managed by it. In
that case, also signal textDocument/didOpen."
;; Called even when revert-buffer-in-progress-p
- (let* ((cur (and buffer-file-name (eglot--current-server)))
+ (let* ((cur (and buffer-file-name (eglot--find-current-server)))
(server (or (and (null server) cur) (and server (eq server cur) cur))))
(when server
+ (setq eglot--unreported-diagnostics `(:just-opened . nil))
(eglot--managed-mode-onoff server 1)
(eglot--signal-textDocument/didOpen))))
"Handle notification window/logMessage") ;; noop, use events buffer
(cl-defmethod eglot-handle-notification
- (_server (_method (eql :telemetry/event)) &rest _any)
+ (_server (_method (eql telemetry/event)) &rest _any)
"Handle notification telemetry/event") ;; noop, use events buffer
- (defvar-local eglot--unreported-diagnostics nil
- "Unreported diagnostics for this buffer.")
-
(cl-defmethod eglot-handle-notification
- (server (_method (eql :textDocument/publishDiagnostics)) &key uri diagnostics)
+ (server (_method (eql textDocument/publishDiagnostics)) &key uri diagnostics)
"Handle notification publishDiagnostics"
(if-let ((buffer (find-buffer-visiting (eglot--uri-to-path uri))))
(with-current-buffer buffer