From be57b545b73224bc92e0ecc87e16efb1c274dcb4 Mon Sep 17 00:00:00 2001 From: Alistair Bill Date: Fri, 3 Mar 2017 21:45:48 +0000 Subject: Add support for nix linting --- ale_linters/nix/nix.vim | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 ale_linters/nix/nix.vim (limited to 'ale_linters') diff --git a/ale_linters/nix/nix.vim b/ale_linters/nix/nix.vim new file mode 100644 index 00000000..27c1d51a --- /dev/null +++ b/ale_linters/nix/nix.vim @@ -0,0 +1,34 @@ +" 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:line in a:lines + let l:match = matchlist(l:line, l:pattern) + + if len(l:match) == 0 + continue + endif + + call add(l:output, { + \ 'bufnr': a:buffer, + \ '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', +\}) -- cgit v1.2.3