diff --git a/doom-modeline-segments.el b/doom-modeline-segments.el index 9d6040f..eda850d 100644 --- a/doom-modeline-segments.el +++ b/doom-modeline-segments.el @@ -1521,21 +1521,23 @@ mouse-3: Describe current input method") ;; LSP ;; +(defun doom-modeline-lsp-icon (text face) + "Display LSP icon (or TEXT in terminal) with FACE." + (if doom-modeline-icon + (doom-modeline-icon-faicon "rocket" :face face :v-adjust -0.0575) + (propertize text 'face face))) + (defvar doom-modeline--lsp nil) (defun doom-modeline-update-lsp (&rest _) "Update `lsp-mode' status." (setq doom-modeline--lsp (concat " " - (let ((icon (if doom-modeline-icon - (doom-modeline-icon-faicon "rocket" :v-adjust -0.0575) - "LSP")) - (workspaces (lsp-workspaces))) + (let* ((workspaces (lsp-workspaces)) + (face (if workspaces 'success 'warning)) + (icon (doom-modeline-lsp-icon "LSP" face))) (propertize icon - 'face (let ((face (if workspaces 'success 'warning))) - (if doom-modeline-icon - `(:height 1.1 :family ,(all-the-icons-icon-family icon) :inherit ,face) - face)) + 'face `(:inherit ,(get-text-property 0 'face icon)) 'help-echo (if workspaces (concat "LSP Connected " (string-join (--map (format "[%s]\n" (lsp--workspace-print it)) @@ -1572,10 +1574,7 @@ mouse-1: Reload to start server") (defun doom-modeline-update-eglot () "Update `eglot' status." (setq doom-modeline--eglot - (pcase-let* ((icon (if doom-modeline-icon - (doom-modeline-icon-faicon "rocket" :v-adjust -0.0575) - "EGLOT")) - (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)))) @@ -1587,49 +1586,45 @@ mouse-1: Reload to start server") ((and pending (cl-plusp pending)) 'warning) (nick 'success) (t 'mode-line))) - (help-echo (cond - (last-error - (format "EGLOT\nAn error occured: %s + (icon (doom-modeline-lsp-icon "EGLOT" face))) + (concat + " " + (propertize icon + 'face `(:inherit ,(get-text-property 0 'face icon)) + 'help-echo (cond + (last-error + (format "EGLOT\nAn error occured: %s mouse-3: clear this status" (plist-get last-error :message))) - ((and doing (not done-p)) - (format "EGLOT\n%s%s" doing - (if detail (format "%s" detail) ""))) - ((and pending (cl-plusp pending)) - (format "EGLOT\n%d outstanding requests" pending)) - (nick (format "EGLOT Connected (%s/%s) + ((and doing (not done-p)) + (format "EGLOT\n%s%s" doing + (if detail (format "%s" detail) ""))) + ((and pending (cl-plusp pending)) + (format "EGLOT\n%d outstanding requests" pending)) + (nick (format "EGLOT Connected (%s/%s) C-mouse-1: Disply server errors mouse-1: Display server events mouse-2: Quit server mouse-3: Reconnect to server" nick (eglot--major-mode server))) - (t "EGLOT Disconnected"))) - (local-map - (let ((map (make-sparse-keymap))) - (cond - (last-error - (define-key map [mode-line mouse-3] - #'eglot-clear-status)) - ((and pending (cl-plusp pending)) - (define-key map [mode-line mouse-3] - #'eglot-forget-pending-continuations)) - (nick - (define-key map [mode-line C-mouse-1] - #'eglot-stderr-buffer) - (define-key map [mode-line mouse-1] - #'eglot-events-buffer) - (define-key map [mode-line mouse-2] - #'eglot-shutdown) - (define-key map [mode-line mouse-3] - #'eglot-reconnect))) - map))) - (concat - " " - (propertize icon - 'face (if doom-modeline-icon - `(:height 1.1 :family ,(all-the-icons-icon-family icon) :inherit ,face) - face) - 'help-echo help-echo + (t "EGLOT Disconnected")) 'mouse-face '(:box 0) - 'local-map local-map) + 'local-map (let ((map (make-sparse-keymap))) + (cond + (last-error + (define-key map [mode-line mouse-3] + #'eglot-clear-status)) + ((and pending (cl-plusp pending)) + (define-key map [mode-line mouse-3] + #'eglot-forget-pending-continuations)) + (nick + (define-key map [mode-line C-mouse-1] + #'eglot-stderr-buffer) + (define-key map [mode-line mouse-1] + #'eglot-events-buffer) + (define-key map [mode-line mouse-2] + #'eglot-shutdown) + (define-key map [mode-line mouse-3] + #'eglot-reconnect))) + map)) " ")))) (add-hook 'eglot--managed-mode-hook #'doom-modeline-update-eglot)