diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2020-04-25 21:30:46 +0200 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2020-04-25 21:30:46 +0200 |
commit | d757bfd643cc73c2d495355c153ed0257f5d5b47 (patch) | |
tree | ff210950456938a779d98f6a2ba7321aca512897 /autoload/vimtex/qf/pplatex.vim | |
parent | 8ec73a3a8974a62a613680a6b6222a77a7b99546 (diff) | |
download | vim-polyglot-d757bfd643cc73c2d495355c153ed0257f5d5b47.tar.gz vim-polyglot-d757bfd643cc73c2d495355c153ed0257f5d5b47.zip |
Change latex provider to luatex, closes #476
Diffstat (limited to 'autoload/vimtex/qf/pplatex.vim')
-rw-r--r-- | autoload/vimtex/qf/pplatex.vim | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/autoload/vimtex/qf/pplatex.vim b/autoload/vimtex/qf/pplatex.vim new file mode 100644 index 00000000..39e9a03e --- /dev/null +++ b/autoload/vimtex/qf/pplatex.vim @@ -0,0 +1,98 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'latex') == -1 + +" vimtex - LaTeX plugin for Vim +" +" CreatedBy: Johannes Wienke (languitar@semipol.de) +" Maintainer: Karl Yngve LervÄg +" Email: karl.yngve@gmail.com +" + +function! vimtex#qf#pplatex#new() abort " {{{1 + return deepcopy(s:qf) +endfunction + +" }}}1 + + +let s:qf = { + \ 'name' : 'LaTeX logfile using pplatex', + \} + +function! s:qf.init(state) abort dict "{{{1 + if !executable('pplatex') + call vimtex#log#error('pplatex is not executable!') + throw 'vimtex: Requirements not met' + endif + + " Automatically remove the -file-line-error option if we use the latexmk + " backend (for convenience) + if a:state.compiler.name ==# 'latexmk' + let l:index = index(a:state.compiler.options, '-file-line-error') + if l:index >= 0 + call remove(a:state.compiler.options, l:index) + endif + endif +endfunction + +function! s:qf.set_errorformat() abort dict "{{{1 + " Each new item starts with two asterics followed by the file, potentially + " a line number and sometimes even the message itself is on the same line. + " Please note that the trailing whitspaces in the error formats are + " intentional as pplatex produces these. + + " Start of new items with file and line number, message on next line(s). + setlocal errorformat=%E**\ Error\ \ \ in\ %f\\,\ Line\ %l:%m + setlocal errorformat+=%W**\ Warning\ in\ %f\\,\ Line\ %l:%m + setlocal errorformat+=%I**\ BadBox\ \ in\ %f\\,\ Line\ %l:%m + + " Start of items with with file, line and message on the same line. There are + " no BadBoxes reported this way. + setlocal errorformat+=%E**\ Error\ \ \ in\ %f\\,\ Line\ %l:%m + setlocal errorformat+=%W**\ Warning\ in\ %f\\,\ Line\ %l:%m + + " Start of new items with only a file. + setlocal errorformat+=%E**\ Error\ \ \ in\ %f:%m + setlocal errorformat+=%W**\ Warning\ in\ %f:%m + setlocal errorformat+=%I**\ BadBox\ \ in\ %f:%m + + " Start of items with with file and message on the same line. There are + " no BadBoxes reported this way. + setlocal errorformat+=%E**\ Error\ in\ %f:%m + setlocal errorformat+=%W**\ Warning\ in\ %f:%m + + " Some errors are difficult even for pplatex + setlocal errorformat+=%E**\ Error\ \ :%m + + " Anything that starts with three spaces is part of the message from a + " previously started multiline error item. + setlocal errorformat+=%C\ \ \ %m\ on\ input\ line\ %l. + setlocal errorformat+=%C\ \ \ %m + + " Items are terminated with two newlines. + setlocal errorformat+=%-Z + + " Skip statistical results at the bottom of the output. + setlocal errorformat+=%-GResult%.%# + setlocal errorformat+=%-G +endfunction + +" }}}1 +function! s:qf.addqflist(tex, log) abort dict " {{{1 + if empty(a:log) || !filereadable(a:log) + throw 'Vimtex: No log file found' + endif + + let l:tmp = fnameescape(fnamemodify(a:log, ':r') . '.pplatex') + let l:log = fnameescape(a:log) + + silent call system(printf('pplatex -i %s >%s', l:log, l:tmp)) + let self.errorformat_saved = &l:errorformat + call self.set_errorformat() + execute 'caddfile' l:tmp + let &l:errorformat = self.errorformat_saved + silent call system('rm ' . l:tmp) +endfunction + +" }}}1 + +endif |