(define-minor-mode eglot--managed-mode
"Mode for source buffers managed by some Eglot project."
- :init-value nil :lighter nil :keymap eglot-mode-map :interactive nil
+ :init-value nil :lighter eglot-mode-line-format :keymap eglot-mode-map :interactive nil
(cond
(eglot--managed-mode
(pcase (plist-get (eglot--capabilities (eglot-current-server))
;;; Mode-line
;;;
(defcustom eglot-mode-line-format
- '(eglot-mode-line-menu
+ '(" "
+ eglot-mode-line-menu
eglot-mode-line-session
eglot-mode-line-error
eglot-mode-line-pending-requests
(put 'eglot-mode-line-action-suggestion 'risky-local-variable t)
(defun eglot--mode-line-props (thing face defs &optional prepend)
- "Helper for function `eglot--mode-line-format'.
+ "Helper for function `eglot-mode-line-format'.
Uses THING, FACE, DEFS and PREPEND."
(cl-loop with map = (make-sparse-keymap)
for (elem . rest) on defs
'keymap eglot--main-menu-map)
"Eglot mode line construct for Eglot's main menu.")
-(defconst eglot-mode-line-session
+(defconst eglot-mode-line-session
'(:eval (when-let* ((server (eglot-current-server))
(nick (eglot-project-nickname server)))
- (propertize
- nick
- 'face 'eglot-mode-line
- 'mouse-face 'mode-line-highlight
- 'help-echo (format "Project '%s'\nmouse-1: LSP server control menu" nick)
- 'keymap eglot--server-menu-map)))
+ (concat
+ ":"
+ (propertize
+ nick
+ 'face 'eglot-mode-line
+ 'mouse-face 'mode-line-highlight
+ 'help-echo (format "Project '%s'\nmouse-1: LSP server control menu" nick)
+ 'keymap eglot--server-menu-map))))
"Eglot mode line construct for project/LSP session.")
(defconst eglot-mode-line-error
'(:eval (when-let* ((server (eglot-current-server))
(last-error (and server (jsonrpc-last-error server))))
(eglot--mode-line-props
- "error" 'compilation-mode-line-fail
+ ":error" 'compilation-mode-line-fail
'((mouse-3 eglot-clear-status "Clear this status"))
(format "An error occurred: %s\n" (plist-get last-error
:message)))))
(pending (jsonrpc-continuation-count server)))
(when (cl-plusp pending)
(eglot--mode-line-props
- (format "%d" pending) 'warning
+ (format ":%d" pending) 'warning
'((mouse-3 eglot-forget-pending-continuations
"Forget pending continuations"))
"Number of outgoing, \
(format "(%s) %s %s" (nth 1 pr)
(nth 2 pr) (nth 3 pr)))
into reports
- finally (return (mapconcat #'identity reports " /")))))
+ finally (return (when reports (concat ":" (mapconcat #'identity reports " /")))))))
"Eglot mode line construct for LSP progress reports.")
(defconst eglot-mode-line-action-suggestion
'(:eval
(when (and (memq 'mode-line eglot-code-action-indications)
(overlay-buffer eglot--suggestion-overlay))
- (overlay-get eglot--suggestion-overlay 'eglot--suggestion-tooltip)))
+ (when-let ((res (overlay-get eglot--suggestion-overlay 'eglot--suggestion-tooltip)))
+ (concat ":" res))))
"Eglot mode line construct for at-point code actions.")
-(add-to-list
- 'mode-line-misc-info
- `(eglot--managed-mode
- (" ["
- (:eval
- (cl-loop for e in eglot-mode-line-format
- for render = (format-mode-line e)
- unless (eq render "")
- collect (cons render
- (eq e 'eglot-mode-line-menu))
- into rendered
- finally
- (return (cl-loop for (rspec . rest) on rendered
- for (r . titlep) = rspec
- concat r
- when rest concat (if titlep ":" "/")))))
- "] ")))
-
\f
;;; Flymake customization
;;;