Merge branch 'master' into 'master'

support for eglot generated flymake diagnostics

See merge request jessieh/mood-line!11
This commit is contained in:
qcfu-bu 2023-03-03 05:33:53 +00:00
commit 94dfaa56c0

View File

@ -54,6 +54,7 @@
;; ---------------------------------- ;;
(eval-when-compile
(require 'cl-lib)
(require 'flymake))
;; ---------------------------------- ;;
@ -571,14 +572,6 @@ Counts will be returned in an alist as the `cdr' of the following keys:
(defvar-local mood-line--checker-flymake-text nil)
(defun mood-line--checker-flymake-count-report-type (type)
"Return count of current flymake reports of TYPE."
(let ((count 0))
(dolist (d (flymake-diagnostics))
(when (eq (cl-struct-slot-value 'flymake--diag 'type d) type)
(cl-incf count)))
count))
(defun mood-line--checker-flymake-count-errors ()
"Return alist with count of all current flymake diagnostic reports.
@ -588,9 +581,22 @@ Counts will be returned in an alist as the cdr of the following keys:
`'warning-count' | All warnings reported by checkero
`'issue-count' | All errors and warnings reported by checker
`'all-count' | Everything reported by checker"
(let ((note-count (mood-line--checker-flymake-count-report-type :note))
(error-count (mood-line--checker-flymake-count-report-type :error))
(warning-count (mood-line--checker-flymake-count-report-type :warning)))
(let ((error-count 0)
(warning-count 0)
(note-count 0))
(progn
(cl-loop
with warning-level = (warning-numeric-level :warning)
with note-level = (warning-numeric-level :debug)
for state being the hash-values of flymake--state
do (cl-loop
with diags = (flymake--state-diags state)
for diag in diags do
(let ((severity (flymake--lookup-type-property (flymake--diag-type diag) 'severity
(warning-numeric-level :error))))
(cond ((> severity warning-level) (cl-incf error-count))
((> severity note-level) (cl-incf warning-count))
(t (cl-incf note-count)))))))
`((note-count . ,note-count)
(error-count . ,error-count)
(warning-count . ,warning-count)