-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflycheck-dogma.el
68 lines (53 loc) · 2.31 KB
/
flycheck-dogma.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
;;; flycheck-dogma.el --- flycheck checker for elixir dogma
;; Copyright (C) 2016 by Aaron Jensen
;; Author: Aaron Jensen <aaronjensen@gmail.com>
;; URL: https://github.com/aaronjensen/flycheck-dogma
;; Version: 0.1.0
;; Package-Requires: ((flycheck "29"))
;;; Commentary:
;; This package adds support for dogma to flycheck.
;; To use it, require it and ensure you have elixir-mode set up for flycheck:
;; (eval-after-load 'flycheck
;; '(flycheck-dogma-setup))
;; (add-hook 'elixir-mode-hook 'flycheck-mode)
;;; License:
;; This file is not part of GNU Emacs.
;; However, it is distributed under the same license.
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Code:
(require 'flycheck)
(defun flycheck-dogma--project-root (&rest _ignored)
"Find directory with mix.exs."
(and buffer-file-name
(locate-dominating-file buffer-file-name "mix.exs")))
(flycheck-define-checker elixir-dogma
"Elixir dogma checker."
:command ("mix" "dogma" "--format" "flycheck" source)
:predicate
(lambda ()
(file-exists-p "deps/dogma"))
:error-patterns
(
(info line-start (file-name) ":" line ":" column ": " (or "C" "R" "D") ": " (optional (id (one-or-more (not (any ":")))) ": ") (message) line-end)
(warning line-start (file-name) ":" line ":" column ": " (or "W" "E" "F") ": " (optional (id (one-or-more (not (any ":")))) ": ") (message) line-end))
:working-directory flycheck-dogma--project-root
:modes elixir-mode)
;;;###autoload
(defun flycheck-dogma-setup ()
"Setup flycheck-dogma.
Add `elixir-dogma' to `flycheck-checkers'."
(interactive)
(add-to-list 'flycheck-checkers 'elixir-dogma))
(provide 'flycheck-dogma)
;;; flycheck-dogma.el ends here