summaryrefslogtreecommitdiff
path: root/ale_linters/nix/nix.vim
blob: 0a0c5c3ed478a672af29133a113e4ee1126d2bb9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
" Author: Alistair Bill <@alibabzo>
" Description: nix-instantiate linter for nix files

function! ale_linters#nix#nix#Handle(buffer, lines) abort
    let l:pattern = '^\(.\+\): \(.\+\), at .*:\(\d\+\):\(\d\+\)$'
    let l:output = []

    for l:match in ale#util#GetMatches(a:lines, l:pattern)
        call add(l:output, {
        \   'lnum': l:match[3] + 0,
        \   'col': l:match[4] + 0,
        \   'text': l:match[1] . ': ' . l:match[2],
        \   'type': l:match[1] =~# '^error' ? 'E' : 'W',
        \})
    endfor

    return l:output
endfunction

call ale#linter#Define('nix', {
\   'name': 'nix',
\   'output_stream': 'stderr',
\   'executable': 'nix-instantiate',
\   'command': 'nix-instantiate --parse -',
\   'callback': 'ale_linters#nix#nix#Handle',
\})