summary refs log tree commit diff
path: root/emacs.d/inits/50_flycheck.el
blob: 345e7176562ba3fb9b3d3f252578f590f4f29737 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
(use-package flycheck
  :ensure t
  :defer t
  :preface (progn
             (defun check-source-predicate ()
               (and (executable-find "check.pex")
                    (buffer-file-name)
                    (string-match "src/source/.*\.py$" (buffer-file-name)))))
  :init
  (progn
    (add-hook 'prog-mode-hook 'flycheck-mode)
    (setq-default flycheck-disabled-checkers '(emacs-lisp-checkdoc)))
  :config
  (progn
    (flycheck-define-checker source-check
      "A syntax checker for python source code in Source, using `dist.pex'"
      :command ("check.pex" source)
      ;;; errors are reported like this:
      ;;; E241:ERROR   <file name>:<line> <message>
      :error-patterns ((error line-start (1+ nonl) ":ERROR" (1+ nonl) ":" line (message) line-end))
      :predicate check-source-predicate
      :modes (python-mode))
    (add-to-list 'flycheck-checkers 'source-check)))