Vimtex: How to filter quickfix warnings by regex

Created on 14 Jun 2019  路  10Comments  路  Source: lervag/vimtex

Describe the issue

Usage of the todonotes package will generate warnings in the form

thesis.tex|| LaTeX Warning: Marginpar on page 7 moved.

I don't care about these, since todonotes won't appear in the end result. Is there a way to filter these? I found documentation for g:vimtex_quickfix_latexlog, but if I understand that correctly that only allows filtering of some predefined warnings. Can I specify a custom regex to ignore?

bug

Most helpful comment

Ok, I've added the option now. See :help vimtex_quickfix_latexlog for the updated documentation. Please let me know if something is unclear or if you have further suggestions for improving this.

All 10 comments

You can ignore these warnings with

let g:vimtex_quickfix_latexlog = {'general' : 0}

I think this should suffice for the current warning. However, for flexibility, I could add a "post filter" that is applied after the log file has been parsed in order to allow to filter out entries by the entry text. I think we could use something like this:

let g:vimtex_quickfix_latexlog = {
      \ 'ignore_filters' = [<list of regexes>],
      \}

How does this sound to you?

Wouldn't that also silence a lot of other warnings? I'd like to know about over/underfull hboxes for example. The categories are a bit of a mystery to me.

A regex applied after parsing would be ideal :)

Ok, I've added the option now. See :help vimtex_quickfix_latexlog for the updated documentation. Please let me know if something is unclear or if you have further suggestions for improving this.

A discussion about this warning in the context of todonotes can be found here:

https://tex.stackexchange.com/questions/23977/what-does-the-warning-about-moved-marginpar-mean

IMHO adding a general possibility to filter warnings based on regex is a great way to help in this situation and others to come.

I have two thoughts about it:

  1. I am wondering whether most user would like to have a separate setting g:vimtex_quickfix_latexlog_draft; possibly automatically selected when the class option draft is given. For example, when writing I do not want to see underfull box warnings. What are your thoughts?
  2. IMHO the option g:vimtex_quickfix_latexlog could be streamlined. We could delegate the filtering more or less completely to the newly added option 'ignore_filters'. Of course we should document how to achieve current pre-defined filterings.

    On the other hand it could be considered more user-friendly to have pre-defined filterings, maybe for most standard warnings (e.g. see https://ww2.eng.famu.fsu.edu/~dommelen/l2h/warnings.html which includes the warning of this issue). What are your thoughts?

And for the record: vim 8.1.0311 (21.8.2018) provides the plugin cfilter to filter the quickfix list with :Cfilter! Marginpar (! to select only those which do not match).

Thanks! That solves my problem with

        let g:vimtex_quickfix_latexlog = {
          \ 'ignore_filters': ['LaTeX Warning: Marginpar on page \d\+ moved.'],
        \}

@timokau My pleasure! As @kiryph comments, I think this direction of configuration might make more sense than the previous one.

@kiryph I'll reply "inlne":

  1. I am wondering whether most user would like to have a separate setting g:vimtex_quickfix_latexlog_draft; possibly automatically selected when the class option draft is given. For example, when writing I do not want to see underfull box warnings. What are your thoughts?

I'm not sure. I don't really want to change my options based on my current "writing mode". And I want to keep the options as simple as possible. Perhaps I misunderstand you on this one, and if so: I think it could be better to open a new issue and describe this suggestion in more detail. Then we can discuss that further there.

  1. IMHO the option g:vimtex_quickfix_latexlog could be streamlined. We could delegate the filtering more or less completely to the newly added option 'ignore_filters'. Of course we should document how to achieve current pre-defined filterings.

    On the other hand it could be considered more user-friendly to have pre-defined filterings, maybe for most standard warnings (e.g. see https://ww2.eng.famu.fsu.edu/~dommelen/l2h/warnings.html which includes the warning of this issue). What are your thoughts?

I actually quite agree. When I implemented 'ignore_filters' I found several things that could be improved, and I also recognized that the option is too "daunting". I've opened #1408 to continue this discussion.

And for the record: vim 8.1.0311 (21.8.2018) provides the plugin cfilter to filter the quickfix list with :Cfilter! Marginpar (! to select only those which do not match).

That's useful, but I don't want to let vimtex depend features that are not very readily available. Thus I won't use Cfilter in the vimtex code, but perhaps it is worth mentioning it in the docs. Feel free to suggest an update!

  1. Draft mode (subset of warnings)

I'm not sure. I don't really want to change my options based on my current "writing mode". And I want to keep the options as simple as possible. Perhaps I misunderstand you on this one, and if so

I think you got it right. I was interested whether others would like to see a subset of warnings during drafting and all warnings when finalizing the document as well.

Apparently, I am here the only one who would use it.

I brought this topic up because the warning Marginpar on page 7 moved due to todonotes would be a good example for this option. As I said I think there are a few other warnings where it makes sense to ignore them until finalizing the document too.

Anyhow, it is not a big deal for me. I can toggle in my vimrc between two settings and reinitialize vimtex to get the desired behavior.

  1. Simplify g:vimtex_quickfix_latexlog by using exclusively regexes to filter

It is good to see that you like this proposal.


My note about :Cfilter was actually not meant as an implementation suggestion for vimtex but a possibility for user to manually filter the quickfix list.

It might be possible that Cfilter can be invoked by the autocmd QuickFixCmdPost to filter the list after vimtex has filled it. However, I think many people appreciate that vimtex supports this out-of-the-box (supports more vim versions and is easier to setup).

Anyhow, it is not a big deal for me. I can toggle in my vimrc between two settings and reinitialize vimtex to get the desired behavior.

I guess you can even create a relatively simple mapping for automating this. And I don't think you need to use VimtexReload, instead, you can use call vimtex#qf#init_state(b:vimtex). That should create a new state for the qf instance that applies the updated configuration.

It is good to see that you like this proposal.

Feel free to comment on #1408, where I have a concrete suggestion for how to modify the code.

However, I think many people appreciate that vimtex supports this out-of-the-box (supports more vim versions and is easier to setup).

Agreed!

I guess you can even create a relatively simple mapping for automating this. And I don't think you need to use VimtexReload, instead, you can use call vimtex#qf#init_state(b:vimtex). That should create a new state for the qf instance that applies the updated configuration.

Thanks for the suggestion.

Feel free to comment on #1408, where I have a concrete suggestion for how to modify the code.

Right now this looks like what I had in mind.

Thanks for the suggestion.

Np! :)

Right now this looks like what I had in mind.

Good, I appreciate the feedback.

Was this page helpful?
0 / 5 - 0 ratings