summaryrefslogtreecommitdiff
path: root/ale_linters/dafny/dafny.vim
blob: 8a114d22d5c98335d8b69e2ae7c6dae8213deb01 (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
37
38
39
40
41
" Author: Taylor Blau <me@ttaylorr.com>
call ale#Set('dafny_dafny_timelimit', 10)

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

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

    for l:match in ale#util#GetMatches(a:lines, '\v(.*)\((\d+),(\d+)\): (Verification of .{-} timed out after \d+ seconds)')
        call add(l:output, {
        \     'filename': l:match[1],
        \     'col': l:match[3] + 0,
        \     'lnum': l:match[2] + 0,
        \     'text': l:match[4],
        \     'type': 'E',
        \ })
    endfor

    return l:output
endfunction

function! ale_linters#dafny#dafny#GetCommand(buffer) abort
    return printf('dafny %%s /compile:0 /timeLimit:%d', ale#Var(a:buffer, 'dafny_dafny_timelimit'))
endfunction

call ale#linter#Define('dafny', {
\    'name': 'dafny',
\    'executable': 'dafny',
\    'command': function('ale_linters#dafny#dafny#GetCommand'),
\    'callback': 'ale_linters#dafny#dafny#Handle',
\    'lint_file': 1,
\ })