branch: elpa/nix-mode
commit 56a87c8d81a6f640eeb151adb3b1ba6ec9636cd0
Author: Matthew Bauer <[email protected]>
Commit: Matthew Bauer <[email protected]>
Move nix-flycheck to separate file.
---
nix-flycheck.el | 39 +++++++++++++++++++++++++++++++++++++++
nix-mode.el | 42 ++----------------------------------------
2 files changed, 41 insertions(+), 40 deletions(-)
diff --git a/nix-flycheck.el b/nix-flycheck.el
new file mode 100644
index 0000000000..1a61e5fd1e
--- /dev/null
+++ b/nix-flycheck.el
@@ -0,0 +1,39 @@
+;;; Flycheck
+
+(require 'flycheck)
+
+(defconst nix-err-msg-re
+ "error: \\(.*\\) at \\(.*\\):\\([0-9]+\\):\\([0-9]+\\)")
+
+(defun nix--parse-errors (output checker buffer)
+ (with-temp-buffer
+ (insert output)
+ (goto-char (point-min))
+ (let ((errs '()))
+ (while (search-forward-regexp nix-err-msg-re nil t 1)
+ (let* ((file (match-string 2))
+ (line (string-to-number (match-string 3)))
+ (col (string-to-number (match-string 4)))
+ (msg (match-string 1)))
+ (setq errs
+ (cons (flycheck-error-new-at
+ line col 'error msg
+ :filename (and (not (string= file "(string)")) file)
+ :checker checker
+ :buffer buffer)
+ errs))))
+ errs)))
+
+(flycheck-def-args-var flycheck-nix-args (nix))
+
+(flycheck-define-checker nix
+ "A syntax and evaluation checker for Nix using
nix-instantiate."
+ :command ("nix-instantiate" "--eval" "--strict"
"--show-trace" (eval flycheck-nix-args) "-")
+ :standard-input t
+ :error-parser nix--parse-errors
+ :modes (nix-mode)
+ )
+
+(add-to-list 'flycheck-checkers 'nix)
+
+(provide 'nix-flycheck)
diff --git a/nix-mode.el b/nix-mode.el
index 8153293763..8e1d309a7c 100644
--- a/nix-mode.el
+++ b/nix-mode.el
@@ -16,7 +16,6 @@
;;; Code:
(require 'company)
-(require 'flycheck)
;; Emacs 24.2 compatability
(unless (fboundp 'setq-local)
@@ -176,41 +175,6 @@ If a close brace `}' ends an antiquote, the next character
begins a string."
(0 (ignore (nix-syntax-propertize-close-brace)))))
start end))
-;;; Flycheck
-
-(defconst nix-err-msg-re
- "error: \\(.*\\) at \\(.*\\):\\([0-9]+\\):\\([0-9]+\\)")
-
-(defun nix--parse-errors (output checker buffer)
- (with-temp-buffer
- (insert output)
- (goto-char (point-min))
- (let ((errs '()))
- (while (search-forward-regexp nix-err-msg-re nil t 1)
- (let* ((file (match-string 2))
- (line (string-to-number (match-string 3)))
- (col (string-to-number (match-string 4)))
- (msg (match-string 1)))
- (setq errs
- (cons (flycheck-error-new-at
- line col 'error msg
- :filename (and (not (string= file "(string)")) file)
- :checker checker
- :buffer buffer)
- errs))))
- errs)))
-
-(flycheck-def-args-var flycheck-nix-args (nix))
-
-(flycheck-define-checker nix
- "A syntax and evaluation checker for Nix using nix-instantiate."
- :command ("nix-instantiate" "--eval" "--strict" "--show-trace" (eval
flycheck-nix-args) "-")
- :standard-input t
- :error-parser nix--parse-errors
- :modes (nix-mode)
- )
-
-(add-to-list 'flycheck-checkers 'nix)
;;; REPL
@@ -529,6 +493,8 @@ If a close brace `}' ends an antiquote, the next character
begins a string."
(nix-create-keymap)
(nix-create-menu)
+(when (featurep 'flycheck) (require 'nix-flycheck))
+
;;;###autoload
(define-derived-mode nix-mode prog-mode "Nix"
"Major mode for editing Nix expressions.
@@ -583,10 +549,6 @@ The hook `nix-mode-hook' is run when Nix mode is started.
(easy-menu-add nix-mode-menu nix-mode-map)
- ;; Flycheck
- (flycheck-select-checker 'nix)
- (flycheck-mode)
-
;; Company
(add-to-list 'company-backends 'company-nix)
(company-mode))