summaryrefslogtreecommitdiff
path: root/ale_linters/cairo/scarb.vim
blob: 48212f0b79195904ec995a79dfdebff91a4bb8f1 (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
" Author: 0xhyoga <0xhyoga@gmx.com>,
" Description: scarb for cairo files

function! ale_linters#cairo#scarb#GetScarbExecutable(bufnr) abort
    if ale#path#FindNearestFile(a:bufnr, 'Scarb.toml') isnot# ''
        return 'scarb'
    else
        " if there is no Scarb.toml file, we don't use scarb even if it exists,
        " so we return '', because executable('') apparently always fails
        return ''
    endif
endfunction

function! ale_linters#cairo#scarb#GetCommand(buffer, version) abort
    return 'scarb build'
endfunction

call ale#linter#Define('cairo', {
\   'name': 'scarb',
\   'executable': function('ale_linters#cairo#scarb#GetScarbExecutable'),
\   'command': {buffer -> ale#semver#RunWithVersionCheck(
\       buffer,
\       ale_linters#cairo#scarb#GetScarbExecutable(buffer),
\       '%e --version',
\       function('ale_linters#cairo#scarb#GetCommand'),
\   )},
\   'callback': 'ale#handlers#cairo#HandleCairoErrors',
\   'output_stream': 'both',
\   'lint_file': 1,
\})