liuyinz / mini-echo.el

Show buffer status in echo area , get rid of mode-line!
GNU General Public License v3.0
73 stars 7 forks source link

Please add segment for flycheck #2

Closed Crandel closed 11 months ago

Crandel commented 1 year ago

Flymake is not enough for development, so I'm very dependent on flycheck mode. Please add flycheck segment too.

liuyinz commented 1 year ago

I don't use flycheck now, it's on the todo list now, PR welcome.

Crandel commented 1 year ago

I check doom-modeline and it was not a flycheck status, but lsp-modeline. Will create another issue for this

idlip commented 11 months ago

Getting flycheck status on error count is possible, I just ran doom-modeline implementation of code and it shows count.

(defun doom-modeline--flycheck-count-errors ()
  "Count the number of ERRORS, grouped by level.

Return an alist, where each ITEM is a cons cell whose `car' is an
error level, and whose `cdr' is the number of errors of that
level."
  (let ((info 0) (warning 0) (error 0))
    (mapc
     (lambda (item)
       (let ((count (cdr item)))
         (pcase (flycheck-error-level-compilation-level (car item))
           (0 (cl-incf info count))
           (1 (cl-incf warning count))
           (2 (cl-incf error count)))))
     (flycheck-count-errors flycheck-current-errors))
    `((info . ,info) (warning . ,warning) (error . ,error))))

output:

((info . 0) (warning . 0) (error . 0))

Crandel commented 11 months ago

Hi @idlip, I tried your snippet but it give me this error

Error during redisplay: (mini-echo-update-overlays-when-resized #<frame emacs_float 0x5555c94e4c00>) signaled (wrong-type-argument stringp ((info . 0) (warning . 0) (error . 0)))

My setup was like this.

  (mini-echo-define-segment "flycheck"
    "Return flycheck info of current buffer."
    :fetch
    (when (bound-and-true-p flycheck-mode)
(let ((info 0) (warning 0) (error 0))
    (mapc
     (lambda (item)
       (let ((count (cdr item)))
         (pcase (flycheck-error-level-compilation-level (car item))
           (0 (cl-incf info count))
           (1 (cl-incf warning count))
           (2 (cl-incf error count)))))
     (flycheck-count-errors flycheck-current-errors))
    `((info . ,info) (warning . ,warning) (error . ,error))))
      )
  (mini-echo-mode 1)
)

Sorry I'm total zero in elisp, but it is not possible to use flymake for Go development so I stuck with flycheck.

liuyinz commented 11 months ago

@Crandel @idlip flycheck segment added, please update to latest and check it.

Crandel commented 11 months ago

@liuyinz Works like a charm, thank you very much