mirror of
https://github.com/correl/doom-modeline.git
synced 2024-11-27 11:09:52 +00:00
Fix flymake checker diagnostic counter.
Make the flymake checker rely on flymake--severity instead of just flymake--diag-type, because backends can and do (eg. eglot) specify different diag-types.
This commit is contained in:
parent
45b9a3e3f3
commit
3ebd0228b2
1 changed files with 81 additions and 72 deletions
|
@ -128,6 +128,7 @@
|
||||||
(declare-function flymake--backend-state-diags 'flymake)
|
(declare-function flymake--backend-state-diags 'flymake)
|
||||||
(declare-function flymake--diag-type 'flymake)
|
(declare-function flymake--diag-type 'flymake)
|
||||||
(declare-function flymake--handle-report 'flymake)
|
(declare-function flymake--handle-report 'flymake)
|
||||||
|
(declare-function flymake--severity 'flymake)
|
||||||
(declare-function flymake-disabled-backends 'flymake)
|
(declare-function flymake-disabled-backends 'flymake)
|
||||||
(declare-function flymake-goto-next-error 'flymake)
|
(declare-function flymake-goto-next-error 'flymake)
|
||||||
(declare-function flymake-goto-prev-error 'flymake)
|
(declare-function flymake-goto-prev-error 'flymake)
|
||||||
|
@ -170,6 +171,7 @@
|
||||||
(declare-function tracking-shorten 'tracking)
|
(declare-function tracking-shorten 'tracking)
|
||||||
(declare-function undo-tree-redo-1 'undo-tree)
|
(declare-function undo-tree-redo-1 'undo-tree)
|
||||||
(declare-function undo-tree-undo-1 'undo-tree)
|
(declare-function undo-tree-undo-1 'undo-tree)
|
||||||
|
(declare-function warning-numeric-level 'warnings)
|
||||||
(declare-function window-numbering-clear-mode-line 'window-numbering)
|
(declare-function window-numbering-clear-mode-line 'window-numbering)
|
||||||
(declare-function window-numbering-get-number-string 'window-numbering)
|
(declare-function window-numbering-get-number-string 'window-numbering)
|
||||||
(declare-function window-numbering-install-mode-line 'window-numbering)
|
(declare-function window-numbering-install-mode-line 'window-numbering)
|
||||||
|
@ -759,31 +761,35 @@ wheel-up/wheel-down: Previous/next error"))
|
||||||
(running (flymake-running-backends))
|
(running (flymake-running-backends))
|
||||||
(disabled (flymake-disabled-backends))
|
(disabled (flymake-disabled-backends))
|
||||||
(reported (flymake-reporting-backends))
|
(reported (flymake-reporting-backends))
|
||||||
(diags-by-type (make-hash-table))
|
|
||||||
(all-disabled (and disabled (null running)))
|
(all-disabled (and disabled (null running)))
|
||||||
(some-waiting (cl-set-difference running reported)))
|
(some-waiting (cl-set-difference running reported)))
|
||||||
(maphash (lambda (_b state)
|
|
||||||
(mapc (lambda (diag)
|
|
||||||
(push diag
|
|
||||||
(gethash (flymake--diag-type diag)
|
|
||||||
diags-by-type)))
|
|
||||||
(flymake--backend-state-diags state)))
|
|
||||||
flymake--backend-state)
|
|
||||||
(when-let
|
(when-let
|
||||||
((icon
|
((icon
|
||||||
(cond
|
(cond
|
||||||
(some-waiting (doom-modeline-checker-icon "access_time" "*" 'doom-modeline-debug))
|
(some-waiting (doom-modeline-checker-icon "access_time" "*" 'doom-modeline-debug))
|
||||||
((null known) (doom-modeline-checker-icon "sim_card_alert" "?" 'doom-modeline-debug))
|
((null known) (doom-modeline-checker-icon "sim_card_alert" "?" 'doom-modeline-debug))
|
||||||
(all-disabled (doom-modeline-checker-icon "sim_card_alert" "!" 'doom-modeline-urgent))
|
(all-disabled (doom-modeline-checker-icon "sim_card_alert" "!" 'doom-modeline-urgent))
|
||||||
(t (let ((.error (length (gethash :error diags-by-type)))
|
(t (let ((.error 0)
|
||||||
(.warning (length (gethash :warning diags-by-type)))
|
(.warning 0)
|
||||||
(.note (length (gethash :note diags-by-type))))
|
(.note 0))
|
||||||
(if (> (+ .error .warning .note) 0)
|
(progn
|
||||||
(doom-modeline-checker-icon "do_not_disturb_alt" "!"
|
(cl-loop
|
||||||
(cond ((> .error 0) 'doom-modeline-urgent)
|
with warning-level = (warning-numeric-level :warning)
|
||||||
((> .warning 0) 'doom-modeline-warning)
|
with note-level = (warning-numeric-level :debug)
|
||||||
(t 'doom-modeline-info)))
|
for state being the hash-values of flymake--backend-state
|
||||||
(doom-modeline-checker-icon "check" "-" 'doom-modeline-info)))))))
|
do (cl-loop
|
||||||
|
with diags = (flymake--backend-state-diags state)
|
||||||
|
for diag in diags do
|
||||||
|
(let ((severity (flymake--severity (flymake--diag-type diag))))
|
||||||
|
(cond ((> severity warning-level) (cl-incf .error))
|
||||||
|
((> severity note-level) (cl-incf .warning))
|
||||||
|
(t (cl-incf .note))))))
|
||||||
|
(if (> (+ .error .warning .note) 0)
|
||||||
|
(doom-modeline-checker-icon "do_not_disturb_alt" "!"
|
||||||
|
(cond ((> .error 0) 'doom-modeline-urgent)
|
||||||
|
((> .warning 0) 'doom-modeline-warning)
|
||||||
|
(t 'doom-modeline-info)))
|
||||||
|
(doom-modeline-checker-icon "check" "-" 'doom-modeline-info))))))))
|
||||||
(propertize
|
(propertize
|
||||||
icon
|
icon
|
||||||
'help-echo (concat "Flymake\n"
|
'help-echo (concat "Flymake\n"
|
||||||
|
@ -826,66 +832,69 @@ mouse-2: Show help for minor mode"
|
||||||
(running (flymake-running-backends))
|
(running (flymake-running-backends))
|
||||||
(disabled (flymake-disabled-backends))
|
(disabled (flymake-disabled-backends))
|
||||||
(reported (flymake-reporting-backends))
|
(reported (flymake-reporting-backends))
|
||||||
(diags-by-type (make-hash-table))
|
|
||||||
(all-disabled (and disabled (null running)))
|
(all-disabled (and disabled (null running)))
|
||||||
(some-waiting (cl-set-difference running reported)))
|
(some-waiting (cl-set-difference running reported))
|
||||||
|
(warning-level (warning-numeric-level :warning))
|
||||||
|
(note-level (warning-numeric-level :debug))
|
||||||
|
(.error 0)
|
||||||
|
(.warning 0)
|
||||||
|
(.note 0))
|
||||||
(maphash (lambda (_b state)
|
(maphash (lambda (_b state)
|
||||||
(mapc (lambda (diag)
|
(cl-loop
|
||||||
(push diag
|
with diags = (flymake--backend-state-diags state)
|
||||||
(gethash (flymake--diag-type diag)
|
for diag in diags do
|
||||||
diags-by-type)))
|
(let ((severity (flymake--severity (flymake--diag-type diag))))
|
||||||
(flymake--backend-state-diags state)))
|
(cond ((> severity warning-level) (cl-incf .error))
|
||||||
|
((> severity note-level) (cl-incf .warning))
|
||||||
|
(t (cl-incf .note))))))
|
||||||
flymake--backend-state)
|
flymake--backend-state)
|
||||||
(let ((.error (length (gethash :error diags-by-type)))
|
(when-let
|
||||||
(.warning (length (gethash :warning diags-by-type)))
|
((text
|
||||||
(.note (length (gethash :note diags-by-type))))
|
(cond
|
||||||
(when-let
|
(some-waiting "Running..." "")
|
||||||
((text
|
((null known) (doom-modeline-checker-text "-" 'doom-modeline-debug))
|
||||||
(cond
|
(all-disabled (doom-modeline-checker-text "-" 'doom-modeline-urgent))
|
||||||
(some-waiting "Running..." "")
|
(t (let ((num (+ .error .warning .note)))
|
||||||
((null known) (doom-modeline-checker-text "-" 'doom-modeline-debug))
|
(when (> num 0)
|
||||||
(all-disabled (doom-modeline-checker-text "-" 'doom-modeline-urgent))
|
(if doom-modeline-checker-simple-format
|
||||||
(t (let ((num (+ .error .warning .note)))
|
(doom-modeline-checker-text (number-to-string num)
|
||||||
(when (> num 0)
|
(cond ((> .error 0) 'doom-modeline-urgent)
|
||||||
(if doom-modeline-checker-simple-format
|
((> .warning 0) 'doom-modeline-warning)
|
||||||
(doom-modeline-checker-text (number-to-string num)
|
(t 'doom-modeline-info)))
|
||||||
(cond ((> .error 0) 'doom-modeline-urgent)
|
(format "%s/%s/%s"
|
||||||
((> .warning 0) 'doom-modeline-warning)
|
(doom-modeline-checker-text (number-to-string .error)
|
||||||
(t 'doom-modeline-info)))
|
'doom-modeline-urgent)
|
||||||
(format "%s/%s/%s"
|
(doom-modeline-checker-text (number-to-string .warning)
|
||||||
(doom-modeline-checker-text (number-to-string .error)
|
'doom-modeline-warning)
|
||||||
'doom-modeline-urgent)
|
(doom-modeline-checker-text (number-to-string .note)
|
||||||
(doom-modeline-checker-text (number-to-string .warning)
|
'doom-modeline-info)))))))))
|
||||||
'doom-modeline-warning)
|
(propertize
|
||||||
(doom-modeline-checker-text (number-to-string .note)
|
text
|
||||||
'doom-modeline-info)))))))))
|
'help-echo (cond
|
||||||
(propertize
|
(some-waiting "Running...")
|
||||||
text
|
((null known) "No Checker")
|
||||||
'help-echo (cond
|
(all-disabled "All Checkers Disabled")
|
||||||
(some-waiting "Running...")
|
(t (format "error: %d, warning: %d, note: %d
|
||||||
((null known) "No Checker")
|
|
||||||
(all-disabled "All Checkers Disabled")
|
|
||||||
(t (format "error: %d, warning: %d, note: %d
|
|
||||||
mouse-1: List all problems
|
mouse-1: List all problems
|
||||||
wheel-up/wheel-down: Previous/next problem"
|
wheel-up/wheel-down: Previous/next problem"
|
||||||
.error .warning .note)))
|
.error .warning .note)))
|
||||||
'mouse-face 'mode-line-highlight
|
'mouse-face 'mode-line-highlight
|
||||||
'local-map (let ((map (make-sparse-keymap)))
|
'local-map (let ((map (make-sparse-keymap)))
|
||||||
(define-key map [mode-line mouse-1]
|
(define-key map [mode-line mouse-1]
|
||||||
#'flymake-show-diagnostics-buffer)
|
#'flymake-show-diagnostics-buffer)
|
||||||
(define-key map (vector 'mode-line
|
(define-key map (vector 'mode-line
|
||||||
mouse-wheel-down-event)
|
mouse-wheel-down-event)
|
||||||
(lambda (event)
|
(lambda (event)
|
||||||
(interactive "e")
|
(interactive "e")
|
||||||
(with-selected-window (posn-window (event-start event))
|
(with-selected-window (posn-window (event-start event))
|
||||||
(flymake-goto-prev-error 1 nil t))))
|
(flymake-goto-prev-error 1 nil t))))
|
||||||
(define-key map (vector 'mode-line
|
(define-key map (vector 'mode-line
|
||||||
mouse-wheel-up-event)
|
mouse-wheel-up-event)
|
||||||
(lambda (event)
|
(lambda (event)
|
||||||
(interactive "e")
|
(interactive "e")
|
||||||
(with-selected-window (posn-window (event-start event))
|
(with-selected-window (posn-window (event-start event))
|
||||||
(flymake-goto-next-error 1 nil t))))
|
(flymake-goto-next-error 1 nil t))))
|
||||||
map)))))))
|
map))))))
|
||||||
(advice-add #'flymake--handle-report :after #'doom-modeline-update-flymake-text)
|
(advice-add #'flymake--handle-report :after #'doom-modeline-update-flymake-text)
|
||||||
|
|
||||||
(doom-modeline-def-segment checker
|
(doom-modeline-def-segment checker
|
||||||
|
|
Loading…
Reference in a new issue