Skip to content

Commit

Permalink
feat(qf): handle more warnings
Browse files Browse the repository at this point in the history
refer: #2950
  • Loading branch information
lervag committed May 8, 2024
1 parent 8295ce6 commit bab312e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
7 changes: 7 additions & 0 deletions autoload/vimtex/qf/latexlog.vim
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ function! s:qf.set_errorformat() abort dict "{{{1
setlocal errorformat+=%-Z(%.%#)\ %m\ on\ input\ line\ %l.
setlocal errorformat+=%-C(%.%#)\ %m

setlocal errorformat+=%+W%.%#\ Warning:\ %m\ on\ input\ line\ %l.

" Ignore unmatched lines
setlocal errorformat+=%-G%.%#
endfunction
Expand All @@ -124,6 +126,11 @@ function! s:qf.fix_paths(log) abort dict " {{{1
let l:hbox_cache = {'index': {}, 'paths': {}}

for l:qf in l:qflist
" Clean up some messages
if l:qf.lnum > 0 && l:qf.text =~# 'on input line \d\+.$'
let l:qf.text = substitute(l:qf.text, '\s*on input line \d\+.$', '', '')
endif

" Handle missing buffer/filename: Fallback to the main file (this is always
" correct in single-file projects and is thus a good fallback).
if l:qf.bufnr == 0
Expand Down
2 changes: 2 additions & 0 deletions test/example-quickfix/main.log
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ My plan is to forget the whole thing and hope for the best.
Missing character: There is no ^^A (U+0001) in font [lmroman10-regular]:+tlig;!
{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] (./test.aux)

Class memoir Warning: As of 2018, \fixpdflayout\ is no longer used on input line 4.

./test.tex:11: Undefined control sequence.
l.11 \cdashline
{1-7}
Expand Down
7 changes: 4 additions & 3 deletions test/test-quickfix/test-latexlog.vim
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ let s:qf = getqflist()

let s:n = 0
for s:expect in [
\ {'lnum': 99, 'type': 'W', 'text': 'Package natbib Warning: Citation `Einstein:1905'' on page 1 undefined on input line 99.'},
\ {'lnum': 12, 'type': 'W', 'text': 'Package refcheck Warning: Unused label `eq:my_equation_label'' on input line 12.'},
\ {'lnum': 99, 'type': 'W', 'text': 'Package natbib Warning: Citation `Einstein:1905'' on page 1 undefined'},
\ {'lnum': 12, 'type': 'W', 'text': 'Package refcheck Warning: Unused label `eq:my_equation_label'''},
\ {'lnum': 9, 'type': 'W', 'text': "Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):\n removing `\\gamma'"},
\ {'lnum': 5, 'type': 'W', 'text': "Package hyperref Warning: Composite letter `\\textdotbelow+u'\n not defined in PD1 encoding,\n removing `\\textdotbelow'"},
\ {'lnum': 477, 'type': 'W', 'text': 'LaTeX Warning: Reference `fig:my_picture'' on page 37 undefined on input line 477.'},
\ {'lnum': 477, 'type': 'W', 'text': 'LaTeX Warning: Reference `fig:my_picture'' on page 37 undefined'},
\ {'lnum': 9, 'type': 'W', 'text': 'Overfull \hbox (22.0021pt too wide) in paragraph at lines 9--9'},
\ {'lnum': 0, 'type': 'W', 'text': 'Package biblatex warning: No "backend" specified, using Biber backend. To use BibTex, load biblatex with the "backend=bibtex" option.'},
\ {'lnum': 0, 'type': 'W', 'text': "Package biblatex Warning: Data encoding is 'utf8'.\n Use backend=biber."},
Expand All @@ -31,6 +31,7 @@ for s:expect in [
\ {'lnum': 0, 'type': 'E', 'text': 'Runaway argument?'},
\ {'lnum': 16, 'type': 'E', 'text': 'Paragraph ended before \date was complete.'},
\ {'lnum': 0, 'type': 'W', 'text': 'Missing character: There is no ^^A (U+0001) in font [lmroman10-regular]:+tlig;!'},
\ {'lnum': 4, 'type': 'W', 'text': 'Class memoir Warning: As of 2018, \fixpdflayout\ is no longer used'},
\ {'lnum': 11, 'type': 'E', 'text': "Undefined control sequence.\n\\cdashline"},
\]
call assert_equal(s:expect.lnum, s:qf[s:n].lnum, 'Failed at index ' . s:n)
Expand Down
2 changes: 1 addition & 1 deletion test/test-quickfix/test-spaces.vim
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let s:n = 0
for s:expect in [
\ {'lnum': 0, 'type': 'E', 'text': 'Runaway argument?'},
\ {'lnum': 16, 'type': 'E', 'text': "Paragraph ended before \\date was complete."},
\ {'lnum': 17, 'type': 'W', 'text': "LaTeX Warning: Reference `blabla' on page 1 undefined on input line 17."},
\ {'lnum': 17, 'type': 'W', 'text': "LaTeX Warning: Reference `blabla' on page 1 undefined"},
\ {'lnum': 19, 'type': 'E', 'text': "Undefined control sequence.\n\\test"},
\ {'lnum': 21, 'type': 'E', 'text': "Too many }'s.\n{Hello world!}}"},
\ {'lnum': 23, 'type': 'E', 'text': "Missing $ inserted."},
Expand Down

0 comments on commit bab312e

Please sign in to comment.