-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathflycheck-joker.el
99 lines (81 loc) · 3.94 KB
/
flycheck-joker.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
;;; flycheck-joker.el --- Add Clojure syntax checker (via Joker) to flycheck
;; Copyright (C) 2017 Roman Bataev <roman.bataev@gmail.com>
;;
;; Author: Roman Bataev <roman.bataev@gmail.com>
;; Created: 12 February 2017
;; Version: 1.5.0
;; Package-Requires: ((flycheck "0.18"))
;;; Commentary:
;; This package adds Clojure syntax checker (via Joker) to flycheck. To use it, add
;; to your init.el:
;; (require 'flycheck-joker)
;; Make sure Joker binary is on your path. Joker version v0.9.7 or greater is required.
;; Joker installation instructions are here: https://github.com/candid82/joker#installation
;;
;; Please read about Joker's linter mode to understand its capabilities and limitations:
;; https://github.com/candid82/joker#linter-mode
;; Specifically, it's important to configure Joker to reduce false positives:
;; https://github.com/candid82/joker#reducing-false-positives
;;
;; Please see examples of the errors Joker can catch here:
;; https://github.com/candid82/SublimeLinter-contrib-joker#examples
;;; 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)
(flycheck-define-checker clojure-joker
"A Clojure syntax checker using Joker.
See URL `https://github.com/candid82/joker'."
:command ("joker" "--lint" "-")
:standard-input t
:error-patterns
((error line-start "<stdin>:" line ":" column ": " (0+ not-newline) (or "error: " "Exception: ") (message) line-end)
(warning line-start "<stdin>:" line ":" column ": " (0+ not-newline) "warning: " (message) line-end))
:modes (clojure-mode clojurec-mode)
:predicate (lambda ()
(let ((buffer-file-name (buffer-file-name)))
(if buffer-file-name
(not (string= "edn" (file-name-extension buffer-file-name)))
(when (or (equal 'clojure-mode major-mode)
(equal 'clojurec-mode major-mode))
t)))))
(flycheck-define-checker clojurescript-joker
"A ClojureScript syntax checker using Joker.
See URL `https://github.com/candid82/joker'."
:command ("joker" "--lintcljs" "-")
:standard-input t
:error-patterns
((error line-start "<stdin>:" line ":" column ": " (0+ not-newline) (or "error: " "Exception: ") (message) line-end)
(warning line-start "<stdin>:" line ":" column ": " (0+ not-newline) "warning: " (message) line-end))
:modes (clojurescript-mode))
(flycheck-define-checker edn-joker
"EDN syntax checker using Joker.
See URL `https://github.com/candid82/joker'."
:command ("joker" "--lintedn" "-")
:standard-input t
:error-patterns
((error line-start "<stdin>:" line ":" column ": " (0+ not-newline) (or "error: " "Exception: ") (message) line-end)
(warning line-start "<stdin>:" line ":" column ": " (0+ not-newline) "warning: " (message) line-end))
:modes (clojure-mode clojurec-mode)
:predicate (lambda ()
(let ((buffer-file-name (buffer-file-name)))
(when buffer-file-name
(string= "edn" (file-name-extension buffer-file-name))))))
(add-to-list 'flycheck-checkers 'clojure-joker)
(add-to-list 'flycheck-checkers 'clojurescript-joker)
(add-to-list 'flycheck-checkers 'edn-joker)
(provide 'flycheck-joker)
;;; flycheck-joker.el ends here