Last active
December 17, 2015 17:59
-
-
Save magnars/5649885 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'flycheck) | |
(defun magnars/adjust-flycheck-automatic-syntax-eagerness () | |
"Adjust how often we check for errors based on if there are any. | |
This lets us fix any errors as quickly as possible, but in a | |
clean buffer we're an order of magnitude laxer about checking." | |
(setq flycheck-idle-change-delay | |
(if flycheck-current-errors 0.3 3.0))) | |
;; Each buffer gets its own idle-change-delay because of the | |
;; buffer-sensitive adjustment above. | |
(make-variable-buffer-local 'flycheck-idle-change-delay) | |
(add-hook 'flycheck-after-syntax-check-hook | |
'magnars/adjust-flycheck-automatic-syntax-eagerness) | |
;; Remove newline checks, since they would trigger an immediate check | |
;; when we want the idle-change-delay to be in effect while editing. | |
(setq flycheck-check-syntax-automatically '(save | |
idle-change | |
mode-enabled)) | |
(defun flycheck-handle-idle-change () | |
"Handle an expired idle time since the last change. | |
This is an overwritten version of the original | |
flycheck-handle-idle-change, which removes the forced deferred. | |
Timers should only trigger inbetween commands in a single | |
threaded system and the forced deferred makes errors never show | |
up before you execute another command." | |
(flycheck-clear-idle-change-timer) | |
(flycheck-buffer-automatically 'idle-change)) | |
(provide 'setup-flycheck) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment