summaryrefslogtreecommitdiff
path: root/ale_linters/markdown/mdl.vim
blob: 7e64304c0fc481fb7f64ee983a293623536796c1 (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
" Author: Steve Dignam <steve@dignam.xyz>
" Description: Support for mdl, a markdown linter

function! ale_linters#markdown#mdl#Handle(buffer, lines) abort
    " matches: '(stdin):173: MD004 Unordered list style'
    let l:pattern = ':\(\d*\): \(.*\)$'
    let l:output = []

    for l:line in a:lines
        let l:match = matchlist(l:line, l:pattern)

        if len(l:match) == 0
            continue
        endif

        call add(l:output, {
        \   'bufnr': a:buffer,
        \   'lnum': l:match[1] + 0,
        \   'col': 0,
        \   'text': l:match[2],
        \   'type': 'W',
        \})
    endfor

    return l:output
endfunction

call ale#linter#Define('markdown', {
\   'name': 'mdl',
\   'executable': 'mdl',
\   'command': 'mdl',
\   'callback': 'ale_linters#markdown#mdl#Handle'
\})