summaryrefslogtreecommitdiff
path: root/autoload/ale/handlers/naga.vim
blob: 6480aba6cd813e2f0bcf89b7d461f3eca72e5f3e (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
" Author: rhysd <https://github.com/rhysd>
" Description: Handle errors for naga-cli.

function! ale#handlers#naga#Handle(buffer, lines) abort
    let l:errors = []
    let l:current_error = v:null

    for l:line in a:lines
        if l:line =~# '^error: '
            let l:text = l:line[7:]
            let l:current_error = { 'text': l:text, 'type': 'E' }
            continue
        endif

        if l:current_error isnot v:null
            let l:matches = matchlist(l:line, '\v:(\d+):(\d+)$')

            if !empty(l:matches)
                let l:current_error.lnum = str2nr(l:matches[1])
                let l:current_error.col = str2nr(l:matches[2])
                call add(l:errors, l:current_error)
                let l:current_error = v:null
                continue
            endif
        endif
    endfor

    return l:errors
endfunction