views:

74

answers:

3

I am trying to get makeprg and errorformat working with VIM and jslint, and can't seem to get the error format right for the life of me... I am using the nodejs version of jslint which produces results like:

1 116,9: The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype.
    for (var k in o)

I basically want to match the line number, and column and the error and use the current file for the filename. Anyone know how to do this?

To be clear, I am looking for the errorformat to get this command working. Currently my .vimrc file has

augroup js
    set makeprg=jslint\ %
    set errorformat=%E%>%l,%c:%m,%Z
augroup END

which just isn't working (the jslint works fine, but the errorformat is wrong)...

A: 

I'm not 100% sure on that version. I used one I downloaded and I just changed the jslint.js source to output it right for me. My line looks something like.

var i=0;i<JSLINT.errors.length;i+=1){var e=JSLINT.errors[i];if(e){print(a[0]+':'+e.line+':'+e.reason);

Hope that can help get you close to getting a format working.

Rick
A: 

I've never used this option before, but the examples in help seem to indicate there should be an extra %m at the end of your pattern, or maybe you just need to escape the comma:

set errorformat=%E%>%l\\,%c:%m,%Z%m

Update: Actually there seems to be two numbers in your error string, 1 followed by a space, then 116. Perhaps this would work:

set errorformat=%E%>%n\\ %l\\,%c:%m,%Z%m
too much php
Nope, didn't work...
Kris Erickson
Still no luck...
Kris Erickson
+2  A: 

I actually just stuck JSLint into my makeprg earlier today, and naturally I needed some quickfix support.

I created a branch of node-jslint which outputs JSLint's errors in a GCC-like format. The efm is: %f:%l:%c:%m. If you can use node.js, I recommend using node-jslint (especially if you're working on a node.js/CommonJS project).

As for your original problem: I don't think %> is necessary. If removing that doesn't help, try simply the following:

set efm=%l,%c: %m
strager
I couldn't get the error format to work, but I switched to your fork of jslint (rather than reid's) and that works perfectly... Thanks
Kris Erickson