summaryrefslogtreecommitdiffstats
path: root/.config/nvim/ale_linters/tex/textidote.vim
blob: 9640ef4870a0be8212953a8204a542f742a90516 (plain) (blame)
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
" Author: Jordi Altayo <jordiag@kth.se>
" Description: support for textidote grammar and syntax checker

call ale#Set('tex_textidote_executable', 'textidote')
call ale#Set('tex_textidote_options', '')

function! ale_linters#tex#textidote#Handle(buffer, lines) abort
    let l:pattern = '.*' . expand('%:t:r') . '\.tex(L\(\d\+\)C\(\d\+\)-L\d\+C\d\+): \(.*\)".*"'
    let l:output = []

    for l:match in ale#util#GetMatches(a:lines, l:pattern)
        call add(l:output, {
        \   'lnum': l:match[1] + 0,
        \   'col' : l:match[2] + 0,
        \   'text': l:match[3],
        \   'type': 'E',
        \})
    endfor

    return l:output
endfunction

function! ale_linters#tex#textidote#GetCommand(buffer) abort
    return '%e --no-color --output singleline' . ale#Pad(ale#Var(a:buffer, 'tex_textidote_options')) . ale#Pad('%s')
endfunction

call ale#linter#Define('tex', {
\   'name': 'textidote',
\   'executable': {b -> ale#Var(b, 'tex_textidote_executable')},
\   'command': function('ale_linters#tex#textidote#GetCommand'),
\   'callback': 'ale_linters#tex#textidote#Handle',
\})