prefix argument), do not kill events and output buffers of
SERVER. ."
(interactive (list (eglot--read-server "Shutdown which server"
- (eglot--current-server))
+ (eglot-current-server))
t nil current-prefix-arg))
(eglot--message "Asking %s politely to terminate" (jsonrpc-name server))
(unwind-protect
INTERACTIVE is t if called interactively."
(interactive (append (eglot--guess-contact t) '(t)))
- (let* ((current-server (eglot--current-server))
+ (let* ((current-server (eglot-current-server))
(live-p (and current-server (jsonrpc-running-p current-server))))
(if (and live-p
interactive
(with-current-buffer buffer
;; No need to pass SERVER as an argument: it has
;; been registered in `eglot--servers-by-project',
- ;; so that it can be obtained from the function
- ;; `eglot--current-server' in any managed buffer.
+ ;; so that it can be found (and cached) from
+ ;; `eglot--maybe-activate-editing-mode' in any
+ ;; managed buffer.
(eglot--maybe-activate-editing-mode)))
(setf (eglot--inhibit-autoreconnect server)
(cond
(cond ((null servers)
(eglot--error "No servers!"))
((or (cdr servers) (not dont-if-just-the-one))
- (let* ((default (when-let ((current (eglot--current-server)))
+ (let* ((default (when-let ((current (eglot-current-server)))
(funcall name current)))
(read (completing-read
(if default
(defvar-local eglot--cached-current-server nil
"A cached reference to the current EGLOT server.")
-(defun eglot--current-server ()
- "Find and cache logical EGLOT server for current buffer."
- (or
- eglot--cached-current-server
- (setq eglot--cached-current-server
- (cl-find major-mode
- (gethash (or (project-current)
- `(transient . ,default-directory))
- eglot--servers-by-project)
- :key #'eglot--major-mode))))
+(defun eglot-current-server ()
+ "Return logical EGLOT server for current buffer, nil if none."
+ eglot--cached-current-server)
(defun eglot--current-server-or-lose ()
"Return current logical EGLOT server connection or error."
- (or (eglot--current-server)
+ (or eglot--cached-current-server
(jsonrpc-error "No current JSON-RPC connection")))
(defvar-local eglot--unreported-diagnostics nil
(unless eglot--managed-mode
;; Called when `revert-buffer-in-progress-p' is t but
;; `revert-buffer-preserve-modes' is nil.
- (when (and buffer-file-name (eglot--current-server))
+ (when (and buffer-file-name
+ (or
+ eglot--cached-current-server
+ (setq eglot--cached-current-server
+ (cl-find major-mode
+ (gethash (or (project-current)
+ `(transient . ,default-directory))
+ eglot--servers-by-project)
+ :key #'eglot--major-mode))))
(setq eglot--unreported-diagnostics `(:just-opened . nil))
(eglot--managed-mode)
(eglot--signal-textDocument/didOpen))))
(defun eglot--mode-line-format ()
"Compose the EGLOT's mode-line."
- (pcase-let* ((server (eglot--current-server))
+ (pcase-let* ((server (eglot-current-server))
(nick (and server (eglot--project-nickname server)))
(pending (and server (hash-table-count
(jsonrpc--request-continuations server))))