dotfiles/emacs-lisp/flycheck.org
main 7cc549d2de
Emacs stuff
Signed-off-by: main <magic_rb@redalder.org>
2022-04-18 23:18:02 +02:00

1.8 KiB

Flycheck

Flycheck Posframe

Display flycheck messages in a posframe.

  (use-package flycheck-posframe
    :straight t
    :config
    (setq flycheck-posframe-position 'frame-bottom-right-corner)
    <<flycheck-display-errors-delay>>
    <<lsp-ui-sideline-show-diagnostics>>
    :hook (flycheck-mode . flycheck-posframe-mode))

Flycheck calls flycheck-display-errors-function every flycheck-display-errors-delay.

  (setq flycheck-display-errors-delay 0.1)

Since we get errors and such in a posframe, we don't need them in the sideline.

  (setq lsp-ui-sideline-show-diagnostics nil)

Since flycheck recalls flycheck-display-errors-function on every point movement, it creates this really ugly flicker and also lags a bit, so if the diagnostic message didn't change, filter out the call.

  (defvar flycheck-posframe-last-error-list '())

  (advice-add
   'flycheck-posframe-hidehandler
   :override
   (lambda (info)
     (if (not (equal
                 (flycheck-overlay-errors-at (point))
                 flycheck-posframe-last-error-list))
         (progn
           (setq flycheck-posframe-last-error-list nil)
           t)
       nil))
   '((name . "flycheck-error-display-filter")))

  (advice-add
   'flycheck-posframe-show-posframe
   :before-while
   (lambda (diagnostic)
     (let ((last-list flycheck-posframe-last-error-list))
       (setq flycheck-posframe-last-error-list diagnostic)
       (if (equal diagnostic last-list) nil t)))
   '((name . "flycheck-error-display-filter")))