summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffrey Lau <9203+zoonfafer@users.noreply.github.com>2022-02-02 09:54:07 +0800
committerGitHub <noreply@github.com>2022-02-02 10:54:07 +0900
commita81512cfd2d7eed294f4ddc9b525a015e5ec9285 (patch)
treeffa58b8d59c43edb33d30cd342e136668ea29bec
parentda1e4dcd1e5ebf340b1edbedb18dc2ba139e6e40 (diff)
downloadale-a81512cfd2d7eed294f4ddc9b525a015e5ec9285.zip
Fix unhandled nix versions for linter 'nix' (#4045)HEADmaster
Previously, it would not generate any lint messages for nix 2.5. Moreover, it would cause this error whenever the nix command is invoked, when paired with a custom `g:ale_command_wrapper`: Error detected while processing function <SNR>92_NeoVimCallback[29]..<lambda>27[ 1]..<SNR>90_ExitCallback[28]..ale_linters#nix#nix#Command: line 1: E684: list index out of range: 0
-rw-r--r--ale_linters/nix/nix.vim2
-rw-r--r--test/handler/test_nix_handler.vader40
2 files changed, 41 insertions, 1 deletions
diff --git a/ale_linters/nix/nix.vim b/ale_linters/nix/nix.vim
index 3d91a9ec..7c2ce963 100644
--- a/ale_linters/nix/nix.vim
+++ b/ale_linters/nix/nix.vim
@@ -5,7 +5,7 @@
function! ale_linters#nix#nix#Command(buffer, output, meta) abort
let l:version = a:output[0][22:]
- if l:version =~# '^\(2.4\|3\).*'
+ if l:version =~# '^\(2.[4-9]\|3\).*'
return 'nix-instantiate --log-format internal-json --parse -'
else
return 'nix-instantiate --parse -'
diff --git a/test/handler/test_nix_handler.vader b/test/handler/test_nix_handler.vader
index 87e8b68f..db6b9a4b 100644
--- a/test/handler/test_nix_handler.vader
+++ b/test/handler/test_nix_handler.vader
@@ -49,3 +49,43 @@ Execute(The nix handler should parse message from old nix-instantiate correctly)
\ 'error: syntax error, unexpected IN, at /path/to/filename.nix:23:14',
\ 'error: syntax error, unexpected ''='', expecting '';'', at /path/to/filename.nix:3:12',
\ ])
+
+Execute(The nix command should not add 'log-format' option for nix version 2.3):
+ AssertEqual
+ \ 'nix-instantiate --parse -',
+ \ ale_linters#nix#nix#Command('', ['nix-instantiate (Nix) 2.3.0'], '')
+
+Execute(The nix command should add 'log-format' option for nix version 2.4):
+ AssertEqual
+ \ 'nix-instantiate --log-format internal-json --parse -',
+ \ ale_linters#nix#nix#Command('', ['nix-instantiate (Nix) 2.4.1'], '')
+
+Execute(The nix command should add 'log-format' option for nix version 2.5):
+ AssertEqual
+ \ 'nix-instantiate --log-format internal-json --parse -',
+ \ ale_linters#nix#nix#Command('', ['nix-instantiate (Nix) 2.5.0pre20211206_d1aaa7e'], '')
+
+Execute(The nix command should add 'log-format' option for nix version 2.6):
+ AssertEqual
+ \ 'nix-instantiate --log-format internal-json --parse -',
+ \ ale_linters#nix#nix#Command('', ['nix-instantiate (Nix) 2.6.0pre20211206_ignored'], '')
+
+Execute(The nix command should add 'log-format' option for nix version 2.7):
+ AssertEqual
+ \ 'nix-instantiate --log-format internal-json --parse -',
+ \ ale_linters#nix#nix#Command('', ['nix-instantiate (Nix) 2.7.0pre20211206_ignored'], '')
+
+Execute(The nix command should add 'log-format' option for nix version 2.8):
+ AssertEqual
+ \ 'nix-instantiate --log-format internal-json --parse -',
+ \ ale_linters#nix#nix#Command('', ['nix-instantiate (Nix) 2.8.0pre20211206_ignored'], '')
+
+Execute(The nix command should add 'log-format' option for nix version 2.9):
+ AssertEqual
+ \ 'nix-instantiate --log-format internal-json --parse -',
+ \ ale_linters#nix#nix#Command('', ['nix-instantiate (Nix) 2.9.0pre20211206_ignored'], '')
+
+Execute(The nix command should add 'log-format' option for nix version 3.0):
+ AssertEqual
+ \ 'nix-instantiate --log-format internal-json --parse -',
+ \ ale_linters#nix#nix#Command('', ['nix-instantiate (Nix) 3.0.0pre20211206_ignored'], '')