[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/nix-mode 6eb927f3c1 080/500: Add basic flychecking via nix
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/nix-mode 6eb927f3c1 080/500: Add basic flychecking via nix-instantiate |
Date: |
Sat, 29 Jan 2022 08:26:37 -0500 (EST) |
branch: elpa/nix-mode
commit 6eb927f3c177ebf23375b31c9a9950cfdb536b45
Author: Leon Isenberg <ljli@users.noreply.github.com>
Commit: Matthew Bauer <mjbauer95@gmail.com>
Add basic flychecking via nix-instantiate
---
nix-mode.el | 46 ++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 44 insertions(+), 2 deletions(-)
diff --git a/nix-mode.el b/nix-mode.el
index 999bbdc100..309a5090af 100644
--- a/nix-mode.el
+++ b/nix-mode.el
@@ -15,6 +15,8 @@
;;; Code:
+(require 'flycheck)
+
;; Emacs 24.2 compatability
(unless (fboundp 'setq-local)
(defmacro setq-local (var val)
@@ -173,7 +175,43 @@ If a close brace `}' ends an antiquote, the next character
begins a string."
(0 (ignore (nix-syntax-propertize-close-brace)))))
start end))
-;; Indentation
+;;; 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 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)
+
+;;; Indentation
(defun nix-indent-level-parens ()
"Find indent level based on parens."
@@ -410,7 +448,11 @@ The hook `nix-mode-hook' is run when Nix mode is started.
(setq-local paragraph-start "[ \t]*\\(#+[ \t]*\\)?$")
(setq-local paragraph-separate paragraph-start)
- (easy-menu-add nix-mode-menu nix-mode-map))
+ (easy-menu-add nix-mode-menu nix-mode-map)
+
+ ;; Flycheck
+ (flycheck-select-checker 'nix)
+ (flycheck-mode))
;;;###autoload
(progn
- [nongnu] elpa/nix-mode 76ad5882f0 046/500: format, (continued)
- [nongnu] elpa/nix-mode 76ad5882f0 046/500: format, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 3ef4647aa2 052/500: Fixup lets/ins counting., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 0ad464e25a 058/500: Add ']' to match closing parens., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 376cbff828 054/500: More let fixes., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 1a1ce340af 070/500: Fix indentation case when '{' at beginning., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode dc705bb4df 057/500: Disable generic hanging indent., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 2be81fe55b 074/500: Get rid of match-end., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 4ce19a966b 095/500: Merge branch 'ljli-fontication', ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 1e58da56ac 083/500: Fix var name nix-err-msg-re, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode b1078c6add 092/500: Add case sensitive searching, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 6eb927f3c1 080/500: Add basic flychecking via nix-instantiate,
ELPA Syncer <=
- [nongnu] elpa/nix-mode afb1629922 085/500: Fix nix--antiquote-open, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 1ebbd318d2 089/500: Add some comments to nix-flycheck.el., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 0f12887ea7 082/500: Add basic company completions via nix-repl, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 5b63478bcb 109/500: Make nix-flycheck optional., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 4076a86333 114/500: Merge pull request #17 from matthewbauer/separate-files, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 2f3dfd90df 115/500: Make nix-format.el optional in nix-mode., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode da7e6de79a 139/500: Move some unpolished elisp to "misc" folder., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 55b0ea2d96 132/500: Merge pull request #18 from matthewbauer/more-modes, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode d9c1d4d4a4 152/500: Remove maintained modes, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 594b979c91 140/500: Missed one, ELPA Syncer, 2022/01/29