All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " Author: Alistair Bill <@alibabzo>
2 " Author: Maximilian Bosch <maximilian@mbosch.me>
3 " Description: nix-instantiate linter for nix files
5 function! ale_linters#nix#nix#Command(buffer, output, meta) abort
6 let l:version = a:output[0][22:]
8 if l:version =~# '^\(1\|2.[0-3]\.\).*'
9 return 'nix-instantiate --parse -'
11 return 'nix-instantiate --log-format internal-json --parse -'
15 function! ale_linters#nix#nix#Handle(buffer, lines) abort
22 if a:lines[0] =~# '^@nix .*'
24 if l:line =~# '^@nix .*'
25 let l:result = json_decode(strpart(l:line, 4))
27 if has_key(l:result, 'column')
30 \ 'lnum': l:result.line,
31 \ 'col': l:result.column,
32 \ 'text': substitute(l:result.raw_msg, '\e\[[0-9;]*m', '', 'g'),
38 let l:pattern = '^\(.\+\): \(.\+\) at .*:\(\d\+\):\(\d\+\)$'
40 for l:match in ale#util#GetMatches(a:lines, l:pattern)
42 \ 'lnum': l:match[3] + 0,
43 \ 'col': l:match[4] + 0,
44 \ 'text': l:match[1] . ': ' . substitute(l:match[2], ',$', '', ''),
45 \ 'type': l:match[1] =~# '^error' ? 'E' : 'W',
53 call ale#linter#Define('nix', {
55 \ 'output_stream': 'stderr',
56 \ 'executable': 'nix-instantiate',
57 \ 'command': {buffer -> ale#command#Run(
59 \ 'nix-instantiate --version',
60 \ function('ale_linters#nix#nix#Command')
62 \ 'callback': 'ale_linters#nix#nix#Handle',