2018-03-31 10:55:20 -04:00
|
|
|
" Author: John Nduli https://github.com/jnduli
|
|
|
|
" Description: Rstcheck for reStructuredText files
|
|
|
|
|
|
|
|
function! ale_linters#rst#rstcheck#Handle(buffer, lines) abort
|
|
|
|
" matches: 'bad_rst.rst:1: (SEVERE/4) Title overline & underline
|
|
|
|
" mismatch.'
|
|
|
|
let l:pattern = '\v^(.+):(\d*): \(([a-zA-Z]*)/\d*\) (.+)$'
|
|
|
|
let l:dir = expand('#' . a:buffer . ':p:h')
|
|
|
|
let l:output = []
|
2018-09-24 20:40:17 -04:00
|
|
|
|
2018-03-31 10:55:20 -04:00
|
|
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
|
|
|
call add(l:output, {
|
|
|
|
\ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]),
|
|
|
|
\ 'lnum': l:match[2] + 0,
|
|
|
|
\ 'col': 0,
|
|
|
|
\ 'type': l:match[3] is# 'SEVERE' ? 'E' : 'W',
|
|
|
|
\ 'text': l:match[4],
|
|
|
|
\})
|
|
|
|
endfor
|
|
|
|
|
|
|
|
return l:output
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
call ale#linter#Define('rst', {
|
|
|
|
\ 'name': 'rstcheck',
|
|
|
|
\ 'executable': 'rstcheck',
|
2021-05-05 04:25:00 -04:00
|
|
|
\ 'cwd': '%s:h',
|
|
|
|
\ 'command': 'rstcheck %t',
|
2018-03-31 10:55:20 -04:00
|
|
|
\ 'callback': 'ale_linters#rst#rstcheck#Handle',
|
|
|
|
\ 'output_stream': 'both',
|
|
|
|
\})
|