flycheck / flycheck-color-mode-line

An Emacs minor-mode for Flycheck which colors the mode-line according to the Flycheck state of the current buffer.
59 stars 5 forks source link

Add support for LSP mode flycheck levels #5

Closed dpassen closed 1 year ago

dpassen commented 1 year ago

lsp-mode is emitting flycheck errors, warnings, and info with levels like lsp-flycheck-info-unnecessary, lsp-flycheck-warning-unnecessary, etc.

These do not trigger these predicates. Is it possible to use flycheck-error-level-compilation-level to integrate them into this package?

purcell commented 1 year ago

Does this do the trick?

diff --git a/flycheck-color-mode-line.el b/flycheck-color-mode-line.el
index 242fbdf..0a270f0 100644
--- a/flycheck-color-mode-line.el
+++ b/flycheck-color-mode-line.el
@@ -110,11 +110,11 @@ Used to restore the original mode line face.")
   (let ((face (pcase status
                 (`finished
                  (cond
-                  ((flycheck-has-current-errors-p 'error)
+                  ((flycheck-has-max-current-errors-p 'error)
                    'flycheck-color-mode-line-error-face)
-                  ((flycheck-has-current-errors-p 'warning)
+                  ((flycheck-has-max-current-errors-p 'warning)
                    'flycheck-color-mode-line-warning-face)
-                  ((flycheck-has-current-errors-p 'info)
+                  ((flycheck-has-max-current-errors-p 'info)
                    'flycheck-color-mode-line-info-face)
                   (t
                    'flycheck-color-mode-line-success-face)))
dpassen commented 1 year ago

The way I'm reading the docstring ("Check if there is no current error more severe than LEVEL.") and looking at results, I think the order would have to go 'info -> 'warning -> 'error.

purcell commented 1 year ago

Oh, quite right...

purcell commented 1 year ago

I don't use this package any more but if you suggest a revised snipped I can commit it.

dpassen commented 1 year ago

I'll keep hacking at it. Thanks :-)

purcell commented 1 year ago

For the success case, might need to check for the current error list being empty, dunno.

dpassen commented 1 year ago

Quite right

dpassen commented 1 year ago
(cond
 ((not (flycheck-has-current-errors-p))
  'flycheck-color-mode-line-success-face)
 ((flycheck-has-max-current-errors-p 'info)
  'flycheck-color-mode-line-info-face)
 ((flycheck-has-max-current-errors-p 'warning)
  'flycheck-color-mode-line-warning-face)
 ((flycheck-has-max-current-errors-p 'error)
  'flycheck-color-mode-line-error-face)
 (t
  'flycheck-color-mode-line-success-face))

Can probably remove the t case. Want to test this some more.

dpassen commented 1 year ago

Draft PR up. #6

purcell commented 1 year ago

Fixed by #6