Search code examples
sortingvimsyntastic

Vim & Syntastic: Sorting Errors before Warnings in the location list


I've found that some warnings can be affected by the presence of a syntax error.

Remove the error and, hey presto, the warning disappears or changes.

So as to not waste time dealing with fake warnings, I want to deal with the errors first, meaning that they would need to appear first in vim's location list.

Syntastic can sort, but :help syntastic-config-sort says it's by line number, then by type, then by column number. The only other option is to display in the order displayed by the generating compiler/checker... which is not configurable.

I know that I could do something like:

let g:syntastic_ruby_checkers=['errors-only', 'warnings-and-errors']

but that would further slow down the already slow-ish checking process in the general case where there are warnings but no errors.

Any way to get errors before warnings?

Or a work-around?

For instance, is there any way to run errors-only if an error is detected in the warnings-and-errors checker?

Or is there a way to: let g:syntastic_quiet_messages = { "level" : "warnings" } only if the list is empty for "level" : "errors"?


Solution

  • My work-around for fixing errors before warnings is to populate the location list with the errors first, followed by the warnings:

    let g:syntastic_ruby_checkers=['mri', 'rubocop']
    

    If I save after fixing errors, then any fake warnings disappear.