Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nix checker #1164

Merged
merged 1 commit into from
Apr 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

- Protobuf with ``protoc`` [GH-1125]
- systemd-analyze with ``systemd-analyze`` [GH-1135]
- Nix with ``nix-instantiate`` [GH-1164]
- Dockerfile with ``hadolint`` [GH-1194]
- AsciiDoc with ``asciidoctor`` [GH-1167]
- CSS/SCSS/LESS with ``stylelint`` [GH-903]
Expand Down
1 change: 1 addition & 0 deletions Cask
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
(depends-on "lua-mode")
(depends-on "markdown-mode")
(depends-on "mmm-mode")
(depends-on "nix-mode")
(depends-on "php-mode")
(depends-on "processing-mode")
(depends-on "protobuf-mode")
Expand Down
8 changes: 8 additions & 0 deletions doc/languages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,14 @@ to view the docstring of the syntax checker. Likewise, you may use

.. syntax-checker-config-file:: flycheck-markdown-mdl-style

.. supported-language:: Nix

.. syntax-checker:: nix

Check Nix with nix-instantiate_.

.. _nix-instantiate: https://nixos.org/nix/manual/#sec-nix-instantiate

.. supported-language:: Perl

Flycheck checks Perl with `perl` and `perl-perlcritic`.
Expand Down
12 changes: 12 additions & 0 deletions flycheck.el
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ attention to case differences."
racket
rpm-rpmlint
markdown-mdl
nix
rst-sphinx
rst
ruby-rubocop
Expand Down Expand Up @@ -8709,6 +8710,17 @@ See URL `https://github.com/mivok/markdownlint'."
(flycheck-remove-error-file-names "(stdin)" errors)))
:modes (markdown-mode gfm-mode))

(flycheck-define-checker nix
"Nix checker using nix-instantiate.

See URL `https://nixos.org/nix/manual/#sec-nix-instantiate'."
:command ("nix-instantiate" "--parse" source-inplace)
:error-patterns
((error line-start
"error: " (message) " at " (file-name) ":" line ":" column
line-end))
:modes nix-mode)

(defun flycheck-locate-sphinx-source-directory ()
"Locate the Sphinx source directory for the current buffer.

Expand Down
5 changes: 5 additions & 0 deletions test/flycheck-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -3766,6 +3766,11 @@ Why not:
"language/markdown.md" 'markdown-mode
'(1 nil error "First header should be a h1 header" :id "MD002" :checker markdown-mdl)))

(flycheck-ert-def-checker-test nix nix nil
(flycheck-ert-should-syntax-check
"language/nix.nix" 'nix-mode
'(3 1 error "syntax error, unexpected IN, expecting ';'," :checker nix)))

(ert-deftest flycheck-locate-sphinx-source-directory/not-in-a-sphinx-project ()
:tags '(language-rst)
(flycheck-ert-with-resource-buffer "language/rst/errors.rst"
Expand Down
4 changes: 4 additions & 0 deletions test/resources/language/nix.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
let
number = 42
in
number * 10