summaryrefslogtreecommitdiff
path: root/ale_linters/php/hack.vim
blob: 77d3a58870710d408d5aa7eeb14c43029c3a46e3 (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
" Author: Zefei Xuan <https://github.com/zefei>
" Description: Hack type checking (http://hacklang.org/)

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

    for l:match in ale#util#GetMatches(a:lines, l:pattern)
        if a:buffer != bufnr(l:match[1])
            continue
        endif

        call add(l:output, {
        \   'lnum': l:match[2] + 0,
        \   'col': l:match[3] + 0,
        \   'text': l:match[5],
        \})
    endfor

    return l:output
endfunction

call ale#linter#Define('php', {
\   'name': 'hack',
\   'executable': 'hh_client',
\   'command': 'hh_client --retries 0 --retry-if-init false',
\   'callback': 'ale_linters#php#hack#Handle',
\})