ui/doom-modeline: refactor flycheck segment (faster)
This commit is contained in:
parent
50ce083696
commit
c52cb38385
1 changed files with 19 additions and 15 deletions
|
@ -419,24 +419,28 @@ directory, the file name, and its state (modified, read-only or non-existent)."
|
||||||
(propertize text 'face face))
|
(propertize text 'face face))
|
||||||
(if vc-mode " " " ")))
|
(if vc-mode " " " ")))
|
||||||
|
|
||||||
|
(defvar-local +doom-modeline--flycheck nil)
|
||||||
|
(add-hook 'flycheck-after-syntax-check-hook #'+doom-modeline|update-flycheck-segment)
|
||||||
|
(defun +doom-modeline|update-flycheck-segment ()
|
||||||
|
(setq +doom-modeline--flycheck
|
||||||
|
(pcase flycheck-last-status-change
|
||||||
|
('finished (if flycheck-current-errors
|
||||||
|
(let-alist (flycheck-count-errors flycheck-current-errors)
|
||||||
|
(let ((sum (+ (or .error 0) (or .warning 0))))
|
||||||
|
(+doom-ml-icon "do_not_disturb_alt"
|
||||||
|
(number-to-string sum)
|
||||||
|
(if .error 'doom-modeline-urgent 'doom-modeline-warning)
|
||||||
|
-0.25)))
|
||||||
|
(+doom-ml-icon "check" nil 'doom-modeline-info)))
|
||||||
|
('running (+doom-ml-icon "access_time" nil 'font-lock-doc-face -0.25))
|
||||||
|
('no-checker (+doom-ml-icon "sim_card_alert" "-" 'font-lock-doc-face))
|
||||||
|
('errored (+doom-ml-icon "sim_card_alert" "Error" 'doom-modeline-urgent))
|
||||||
|
('interrupted (+doom-ml-icon "pause" "Interrupted" 'font-lock-doc-face)))))
|
||||||
|
|
||||||
(def-modeline-segment! flycheck
|
(def-modeline-segment! flycheck
|
||||||
"Displays color-coded flycheck error status in the current buffer with pretty
|
"Displays color-coded flycheck error status in the current buffer with pretty
|
||||||
icons."
|
icons."
|
||||||
(when (boundp 'flycheck-last-status-change)
|
+doom-modeline--flycheck)
|
||||||
(pcase flycheck-last-status-change
|
|
||||||
('finished (if flycheck-current-errors
|
|
||||||
(let-alist (flycheck-count-errors flycheck-current-errors)
|
|
||||||
(let ((sum (+ (or .error 0) (or .warning 0))))
|
|
||||||
(+doom-ml-icon "do_not_disturb_alt"
|
|
||||||
(number-to-string sum)
|
|
||||||
(if .error 'doom-modeline-urgent 'doom-modeline-warning)
|
|
||||||
-0.25)))
|
|
||||||
(+doom-ml-icon "check" nil 'doom-modeline-info)))
|
|
||||||
('running (+doom-ml-icon "access_time" nil 'font-lock-doc-face -0.25))
|
|
||||||
('no-checker (+doom-ml-icon "sim_card_alert" "-" 'font-lock-doc-face))
|
|
||||||
('errored (+doom-ml-icon "sim_card_alert" "Error" 'doom-modeline-urgent))
|
|
||||||
('interrupted (+doom-ml-icon "pause" "Interrupted" 'font-lock-doc-face)))))
|
|
||||||
;; ('interrupted (+doom-ml-icon "x" "Interrupted" 'font-lock-doc-face)))))
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
(defsubst doom-column (pos)
|
(defsubst doom-column (pos)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue