diff --git a/modules/ui/modeline/+light.el b/modules/ui/modeline/+light.el index 83d2ef6d6..f49ce1c74 100644 --- a/modules/ui/modeline/+light.el +++ b/modules/ui/modeline/+light.el @@ -109,14 +109,22 @@ side of the modeline, and whose CDR is the right-hand side.") (if (eq idx len) "\"};" "\",\n"))))) 'xpm t :ascent 'center))))) -(defun +modeline-format-icon (icon label &optional face help-echo voffset) - (propertize (concat (all-the-icons-material - icon - :face face - :height 1.1 - :v-adjust (or voffset -0.225)) - (propertize label 'face face)) - 'help-echo help-echo)) +(defun +modeline-format-icon (icon-set icon label &optional face help-echo voffset) + "Build from ICON-SET the ICON with LABEL. +Using optionals attributes FACE, HELP-ECHO and VOFFSET." + (let ((icon-set-fn (pcase icon-set + ('octicon #'all-the-icons-octicon) + ('faicon #'all-the-icons-faicon) + ('material #'all-the-icons-material) + ('alltheicon #'all-the-icons-alltheicon) + ('fileicon #'all-the-icons-fileicon)))) + (propertize (concat (funcall icon-set-fn + icon + :face face + :height 1.1 + :v-adjust (or voffset -0.225)) + (propertize label 'face face)) + 'help-echo help-echo))) (defun set-modeline! (name &optional default) "Set the modeline to NAME. @@ -410,7 +418,7 @@ Requires `anzu', also `evil-anzu' if using `evil-mode' for compatibility with (let ((error (or .error 0)) (warning (or .warning 0)) (info (or .info 0))) - (+modeline-format-icon "do_not_disturb_alt" + (+modeline-format-icon 'material "do_not_disturb_alt" (number-to-string (+ error warning info)) (cond ((> error 0) 'error) ((> warning 0) 'warning) @@ -420,10 +428,11 @@ Requires `anzu', also `evil-anzu' if using `evil-mode' for compatibility with warning info)))) (+modeline-format-icon "check" "" 'success))) - (`running (+modeline-format-icon "access_time" "*" 'mode-line-inactive "Running...")) - (`errored (+modeline-format-icon "sim_card_alert" "!" 'error "Errored!")) - (`interrupted (+modeline-format-icon "pause" "!" 'mode-line-inactive "Interrupted")) - (`suspicious (+modeline-format-icon "priority_high" "!" 'error "Suspicious")))))) + (`running (+modeline-format-icon'material "access_time" "*" 'mode-line-inactive "Running...")) + (`errored (+modeline-format-icon'material "sim_card_alert" "!" 'error "Errored!")) + (`interrupted (+modeline-format-icon'material "pause" "!" 'mode-line-inactive "Interrupted")) + (`suspicious (+modeline-format-icon'material "priority_high" "!" 'error "Suspicious")))))) + ;;; `+modeline-selection-info' @@ -476,6 +485,26 @@ lines are selected, or the NxM dimensions of a block selection.") (add-hook 'deactivate-mark-hook #'+modeline-remove-selection-segment-h)) +;;; `+modeline-lsp' +(progn + (def-modeline-var! +modeline-lsp nil + "Display LSP connection status icon for the current buffer." + :local t) + + (add-hook! '(lsp-before-initialize-hook + lsp-after-initialize-hook + lsp-after-uninitialized-functions + lsp-before-open-hook + lsp-after-open-hook) + (defun +modeline-lsp-update (&rest _) + "Update lsp state." + (let* ((workspaces (lsp-workspaces)) + (face (if workspaces 'success 'warning)) + (label (if workspaces "LSP Connected" "LSP Disconnected"))) + (setq +modeline-lsp + (+modeline-format-icon 'faicon "rocket" "" face label -0.0575)))))) + + ;;; `+modeline-encoding' (def-modeline-var! +modeline-encoding `(:eval @@ -508,6 +537,9 @@ lines are selected, or the NxM dimensions of a block selection.") +modeline-position) `("" mode-line-misc-info + " " + +modeline-lsp + " " +modeline-modes (vc-mode (" " ,(all-the-icons-octicon "git-branch" :v-adjust 0.0)