diff options
author | jnduli <yohanaizraeli@gmail.com> | 2017-11-11 15:10:17 +0300 |
---|---|---|
committer | w0rp <w0rp@users.noreply.github.com> | 2017-11-11 12:10:17 +0000 |
commit | 6c014a25e86c864c893c59ee3f30ce80cfd5fbb6 (patch) | |
tree | 941e4de5ef541085f2b56bb2902f233285bba3f2 /ale_linters/rst | |
parent | 1ddc3eec6dff1c35111d47ec6e46cf2f2f699e20 (diff) | |
download | ale-6c014a25e86c864c893c59ee3f30ce80cfd5fbb6.zip |
Add rstcheck linter to check for errors in restructured text (#1090)
Diffstat (limited to 'ale_linters/rst')
-rw-r--r-- | ale_linters/rst/rstcheck.vim | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/ale_linters/rst/rstcheck.vim b/ale_linters/rst/rstcheck.vim new file mode 100644 index 00000000..b660627f --- /dev/null +++ b/ale_linters/rst/rstcheck.vim @@ -0,0 +1,37 @@ +" 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 = [] + 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 + +function! ale_linters#rst#rstcheck#GetCommand(buffer) abort + return ale#path#BufferCdString(a:buffer) + \ . 'rstcheck' + \ . ' %t' +endfunction + + +call ale#linter#Define('rst', { +\ 'name': 'rstcheck', +\ 'executable': 'rstcheck', +\ 'command_callback': 'ale_linters#rst#rstcheck#GetCommand', +\ 'callback': 'ale_linters#rst#rstcheck#Handle', +\ 'output_stream': 'both', +\}) |