tweak(flymake): patch modeline to look project-wide

This commit is contained in:
Kiana Sheibani 2026-02-04 16:38:56 -05:00
parent 41d12e5f3c
commit f28d055c73
Signed by: toki
GPG key ID: 6CB106C25E86A9F7

View file

@ -1920,15 +1920,55 @@ Flymake normally uses italics for warnings, but my italics font being cursive ma
#+begin_src emacs-lisp
(custom-set-faces!
'(compilation-warning :slant normal :weight bold)
'(flymake-note-echo :underline nil :inherit compilation-info))
'(compilation-warning :slant unspecified :weight bold)
'(flymake-note-echo :inherit compilation-info))
#+end_src
And just to make sure nothing else accidentally starts running:
**** Tooltips
#+begin_src emacs-lisp :tangle packages.el
(package! flycheck :disable t)
(package! flyspell :disable t)
Having an IDE-style tooltip pop up is nice, but ~flymake-popon~ is a bit ugly by default.
#+begin_src emacs-lisp
(after! flymake-popon
; Widen popon
(setq flymake-popon-width 120)
; Add visible border
(set-face-foreground 'flymake-popon-posframe-border (doom-color 'selection)))
#+end_src
*** Modeline
In order to obtain as much information as possible about the current state of the program, I like to use Flymake's tools for project-wide diagnostics, rather than the default buffer-specific ones. Unfortunately, Doom's modeline segment for Flymake doesn't support this, so we'll have to patch it in.
#+begin_src emacs-lisp
(defpatch! doom-modeline-segments
(defun doom-modeline--flymake-count-errors) ()
"Count the number of ERRORS, grouped by level."
((el-patch-swap let let*)
((el-patch-add
(project (project-current))
(root (project-root project))
(states (--keep
(and (buffer-file-name it)
(buffer-local-value 'flymake--state it))
(project-buffers project))))
(warning-level (warning-numeric-level :warning))
(note-level (warning-numeric-level :debug))
(note 0) (warning 0) (error 0))
(el-patch-wrap 2
(dolist (st states)
(maphash (lambda (_b state)
(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))
((> severity note-level) (cl-incf warning))
(t (cl-incf note))))))
(el-patch-swap flymake--state st))))
`((note . ,note) (warning . ,warning) (error . ,error))))
#+end_src
*** Bindings