vimerrorformat

Vim errorformat for jshint (with example)


I am trying to write efm for this:

file: app/assets/javascripts/topbar.js
  line 17, col 3, Missing semicolon.
  line 19, col 19, 'is_mobile' was used before it was defined.
  line 21, col 1965, Expected '{' and instead saw 'check'.
  line 25, col 18, 'onScroll' was used before it was defined.
file: app/assets/javascripts/trends.js
  line 2, col 55, Missing semicolon.
  line 6, col 27, 'trendTypeSelected' was used before it was defined.
  line 7, col 32, Expected '===' and instead saw '=='.
JSHint check failed

but I think I am missing the concept of file on separate line. Can someone help me out with this?

This is what I have so far and it does not work:

%-Pfile:\ %f,line\ %l\,\ col\ %c\,\ %m

Thanks!

Solution:

set efm=%-Pfile:\ %f,%*[\ ]line\ %l\\,\ col\ %c\\,\ %m,%-Q,%-GJSHint\ check\ failed

Solution

  • Vim provides %P, which pushes the parsed file (%f) onto the stack, see :help errorformat-separate-filename.

    So for your error output, it would be something like %+Pfile: %f,...