This file contains 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) | |
(require 'flycheck-mypy) | |
(add-hook 'solidity-mode-hook 'flycheck-mode) | |
(add-hook 'solidity-mode-hook | |
(lambda () | |
(set-fill-column 80))) | |
(setq-default flycheck-flake8-maximum-line-length 200) | |
; (setq-default flycheck-disabled-checkers '(emacs-lisp-checkdoc)) | |
(setq-default flycheck-disabled-checkers '(emacs-lisp-checkdoc clojure-cider-typed)) | |
(with-eval-after-load 'flycheck | |
(setq-default flycheck-disabled-checkers '(emacs-lisp-checkdoc))) | |
; (add-hook 'python-mode-hook 'flycheck-mode) ;(add-hook 'after-init-hook #'global-flycheck-mode) | |
(add-hook 'after-init-hook #'global-flycheck-mode) | |
(add-to-list 'flycheck-disabled-checkers 'python-flake8) | |
; (add-to-list 'flycheck-disabled-checkers 'python-pylint) | |
(add-hook 'python-mode-hook | |
(lambda () | |
;(setq flycheck-mypyrc "~/venv/bin/pylint") | |
(setq flycheck-python-pylint-executable "~/venv/bin/pylint") | |
(setq flycheck-pylintrc "~/.pylintrc"))) | |
(flycheck-add-next-checker 'python-flake8 'python-pylint 'python-mypy) | |
(defun flycheck-or-norm-next-error (&optional n reset) | |
(interactive "P") | |
(if flycheck-mode | |
(flycheck-next-error n reset) | |
(next-error n reset))) | |
(defun flycheck-or-norm-previous-error (&optional n) | |
(interactive "P") | |
(if flycheck-mode | |
(flycheck-previous-error n) | |
(previous-error n))) | |
;; Optional: ensure flycheck cycles, both when going backward and forward. | |
;; Tries to handle arguments correctly. | |
;; Since flycheck-previous-error is written in terms of flycheck-next-error, | |
;; advising the latter is enough. | |
(defun flycheck-next-error-loop-advice (orig-fun &optional n reset) | |
; (message "flycheck-next-error called with args %S %S" n reset) | |
(condition-case err | |
(apply orig-fun (list n reset)) | |
((user-error) | |
(let ((error-count (length flycheck-current-errors))) | |
(if (and | |
(> error-count 0) ; There are errors so we can cycle. | |
(equal (error-message-string err) "No more Flycheck errors")) | |
;; We need to cycle. | |
(let* ((req-n (if (numberp n) n 1)) ; Requested displacement. | |
; An universal argument is taken as reset, so shouldn't fail. | |
(curr-pos (if (> req-n 0) (- error-count 1) 0)) ; 0-indexed. | |
(next-pos (mod (+ curr-pos req-n) error-count))) ; next-pos must be 1-indexed | |
; (message "error-count %S; req-n %S; curr-pos %S; next-pos %S" error-count req-n curr-pos next-pos) | |
; orig-fun is flycheck-next-error (but without advise) | |
; Argument to flycheck-next-error must be 1-based. | |
(apply orig-fun (list (+ 1 next-pos) 'reset))) | |
(signal (car err) (cdr err))))))) | |
(advice-add 'flycheck-next-error :around #'flycheck-next-error-loop-advice) | |
;; The following might be needed to ensure flycheck is loaded. | |
;; Hooking is required if flycheck is installed as an ELPA package (from any repo). | |
;; If you use ELPA, you might want to merge this with any existing hook you might have. | |
(add-hook 'after-init-hook | |
#'(lambda () | |
(after-packages-loaded-hook))) | |
(defun after-packages-loaded-hook () | |
(require 'flycheck)) | |
(global-set-key (kbd "M-g p") 'flycheck-or-norm-previous-error) | |
;; flycheck-pycheckers | |
;; Allows multiple syntax checkers to run in parallel on Python code | |
;; Ideal use-case: pyflakes for syntax combined with mypy for typing | |
(use-package flycheck-pycheckers | |
:after flycheck | |
:ensure t | |
:init | |
(with-eval-after-load 'flycheck | |
(add-hook 'flycheck-mode-hook #'flycheck-pycheckers-setup) | |
) | |
(setq flycheck-pycheckers-checkers | |
'( | |
mypy3 | |
pyflakes | |
) | |
) | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment