summaryrefslogtreecommitdiff
path: root/ale_linters/avra/avra.vim
blob: edf15c0927b4291d75aefd4b80af6e16598ab112 (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
27
28
29
30
31
32
33
34
35
36
" Author: Utkarsh Verma <utkarshverma@protonmail.com>
" Description: AVRA linter for avra syntax.

call ale#Set('avra_avra_executable', 'avra')
call ale#Set('avra_avra_options', '')

function! ale_linters#avra#avra#GetCommand(buffer) abort
    return '%e'
    \   . ' %t'
    \   . ale#Pad(ale#Var(a:buffer, 'avra_avra_options'))
    \   . ' -o ' . g:ale#util#nul_file
endfunction

function! ale_linters#avra#avra#Handle(buffer, lines) abort
    " Note that we treat 'fatal' as errors.
    let l:pattern = '^\S\+(\(\d\+\))\s\+:\s\+\(\S\+\)\s\+:\s\+\(.\+\)$'
    let l:output = []

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

    return l:output
endfunction

call ale#linter#Define('avra', {
\   'name': 'avra',
\   'output_stream': 'stderr',
\   'executable': {b -> ale#Var(b, 'avra_avra_executable')},
\   'command': function('ale_linters#avra#avra#GetCommand'),
\   'callback': 'ale_linters#avra#avra#Handle',
\})