diff options
author | w0rp <w0rp@users.noreply.github.com> | 2018-12-06 20:26:04 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-06 20:26:04 +0000 |
commit | 3db564f7742360a870679ef6c63361371646fed8 (patch) | |
tree | c711e395e69d6a8ca870b2632f5c5861276ef9fb /ale_linters | |
parent | fdd37acc1f381230fc2ed87303e98c7a4daafaad (diff) | |
parent | 9e97a6914e1f7f5ab4ac80c33150c42f733d3a1b (diff) | |
download | ale-3db564f7742360a870679ef6c63361371646fed8.zip |
Merge pull request #2061 from hsanson/1910-add-support-for-bibclean-fixer
Add bibclean fixer support
Diffstat (limited to 'ale_linters')
-rw-r--r-- | ale_linters/bib/bibclean.vim | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/ale_linters/bib/bibclean.vim b/ale_linters/bib/bibclean.vim new file mode 100644 index 00000000..6750f22f --- /dev/null +++ b/ale_linters/bib/bibclean.vim @@ -0,0 +1,74 @@ +" Author: Horacio Sanson - https://github.com/hsanson +" Description: Support for bibclean linter for BibTeX files. + +call ale#Set('bib_bibclean_executable', 'bibclean') + +function! ale_linters#bib#bibclean#GetCommand(buffer) abort + let l:executable = ale#Var(a:buffer, 'bib_bibclean_executable') + + return ale#Escape(l:executable) . ' -file-position ' +endfunction + +function! ale_linters#bib#bibclean#get_type(str) abort + if a:str is# '??' + return 'E' + else + return 'W' + endif +endfunction + +function! ale_linters#bib#bibclean#match_msg(line) abort + return matchlist(a:line, '^\(.*\) "stdin", line \(.*\): \(.*\)$') +endfunction + +function! ale_linters#bib#bibclean#match_entry(line) abort + return matchlist(a:line, 'Entry input byte=.* line=\(.*\) column=\(.*\) output .*$') +endfunction + +function! ale_linters#bib#bibclean#match_value(line) abort + return matchlist(a:line, 'Value input byte=.* line=\(.*\) column=\(.*\) output .*$') +endfunction + +function! ale_linters#bib#bibclean#Handle(buffer, lines) abort + let l:output = [] + + let l:type = 'E' + let l:msg = '' + + for l:line in a:lines + if empty(l:msg) + let l:mlist = ale_linters#bib#bibclean#match_msg(l:line) + + if !empty(l:mlist) + let l:msg = l:mlist[3] + let l:type = ale_linters#bib#bibclean#get_type(l:mlist[1]) + endif + else + if l:type is# 'E' + let l:mlist = ale_linters#bib#bibclean#match_entry(l:line) + else + let l:mlist = ale_linters#bib#bibclean#match_value(l:line) + endif + + if !empty(l:mlist) + call add(l:output, { + \ 'lnum': l:mlist[1], + \ 'col': l:mlist[2], + \ 'text': l:msg, + \ 'type': l:type + \}) + let l:msg = '' + endif + endif + endfor + + return l:output +endfunction + +call ale#linter#Define('bib', { +\ 'name': 'bibclean', +\ 'executable_callback': ale#VarFunc('bib_bibclean_executable'), +\ 'command_callback': 'ale_linters#bib#bibclean#GetCommand', +\ 'output_stream': 'stderr', +\ 'callback': 'ale_linters#bib#bibclean#Handle', +\}) |