2019-02-22 00:20:29 -05:00
|
|
|
;;; tools/flycheck/config.el -*- lexical-binding: t; -*-
|
|
|
|
|
|
|
|
(defvar +flycheck-on-escape t
|
|
|
|
"If non-nil, flycheck will recheck the current buffer when pressing ESC/C-g.")
|
|
|
|
|
|
|
|
|
|
|
|
;;
|
2019-04-01 20:30:31 -04:00
|
|
|
;;; Packages
|
2017-02-13 05:51:36 -05:00
|
|
|
|
2017-02-23 00:06:12 -05:00
|
|
|
(def-package! flycheck
|
2018-05-25 00:46:11 +02:00
|
|
|
:commands (flycheck-list-errors flycheck-buffer)
|
2019-03-07 00:26:51 -05:00
|
|
|
:after-call (doom-switch-buffer-hook after-find-file)
|
2017-02-13 05:51:36 -05:00
|
|
|
:config
|
2019-04-01 20:30:31 -04:00
|
|
|
;; new-line checks are a mote excessive; idle checks are more than enough
|
|
|
|
(setq flycheck-check-syntax-automatically
|
|
|
|
(delq 'new-line flycheck-check-syntax-automatically))
|
2017-02-13 05:51:36 -05:00
|
|
|
|
2019-02-22 00:20:29 -05:00
|
|
|
(defun +flycheck|buffer ()
|
|
|
|
"Flycheck buffer on ESC in normal mode."
|
|
|
|
(when (and flycheck-mode +flycheck-on-escape)
|
|
|
|
(ignore-errors (flycheck-buffer))
|
|
|
|
nil))
|
|
|
|
(add-hook 'doom-escape-hook #'+flycheck|buffer t)
|
2019-01-14 00:51:25 -05:00
|
|
|
|
2019-04-01 20:30:31 -04:00
|
|
|
(defun +flycheck|adjust-syntax-check-eagerness ()
|
|
|
|
"Check for errors less often when there aren't any.
|
|
|
|
Done to reduce the load flycheck imposes on the current buffer."
|
|
|
|
(if flycheck-current-errors
|
|
|
|
(kill-local-variable 'flycheck-idle-change-delay)
|
|
|
|
(setq-local flycheck-idle-change-delay 3.0)))
|
|
|
|
(add-hook 'flycheck-after-syntax-check-hook #'+flycheck|adjust-syntax-check-eagerness)
|
2018-06-21 15:54:36 +02:00
|
|
|
|
|
|
|
(global-flycheck-mode +1))
|
2017-02-13 05:51:36 -05:00
|
|
|
|
|
|
|
|
2018-01-05 14:43:44 -05:00
|
|
|
(def-package! flycheck-popup-tip
|
2018-05-25 00:46:11 +02:00
|
|
|
:commands (flycheck-popup-tip-show-popup flycheck-popup-tip-delete-popup)
|
2019-02-28 05:01:04 -05:00
|
|
|
:init (add-hook 'flycheck-mode-hook #'+flycheck|init-popups)
|
2019-04-01 20:30:31 -04:00
|
|
|
:config
|
|
|
|
(setq flycheck-popup-tip-error-prefix "✕ ")
|
|
|
|
(after! evil
|
|
|
|
;; Don't display errors while in insert mode, as it can affect the cursor's
|
|
|
|
;; position or cause disruptive input delays.
|
|
|
|
(add-hook 'flycheck-posframe-inhibit-functions #'evil-insert-state-p)))
|
2018-05-07 18:50:44 +02:00
|
|
|
|
2018-01-05 14:43:44 -05:00
|
|
|
|
2018-05-07 18:50:44 +02:00
|
|
|
(def-package! flycheck-posframe
|
2018-05-25 00:46:11 +02:00
|
|
|
:when (and EMACS26+ (featurep! +childframe))
|
2019-03-01 14:25:18 -05:00
|
|
|
:defer t
|
2019-02-28 05:01:04 -05:00
|
|
|
:init (add-hook 'flycheck-mode-hook #'+flycheck|init-popups)
|
2018-05-09 11:26:06 +02:00
|
|
|
:config
|
|
|
|
(setq flycheck-posframe-warning-prefix "⚠ "
|
|
|
|
flycheck-posframe-info-prefix "··· "
|
|
|
|
flycheck-posframe-error-prefix "✕ "))
|