Question

I have the jslint installed with npm on my system.

It produces error messages in the following format:

  1 1,9: Missing name in function statement.
    function() {
  2 2,11: Use '===' to compare with '0'.
    if (x == 0) {
  3 4,2: Unnecessary semicolon.
    };

I wrote a compiler plugin for Vim to parse the error messages, but I could not figure out the problem with the errorformat. I have the following now in my compiler file:

CompilerSet makeprg=jslint
      \\ $*
      \\ %
CompilerSet errorformat=
    \%*[\ ]%n\ %l\,%c:\ %m,
    \%-G%.%#

Which AFAIK should do the following:

  • %*[\ ] -- skip the whitespaces in the beginning of the line
  • %n -- match the error number
  • \ -- skip a space
  • %l -- match for the line number
  • \, -- skip the comma
  • %c -- match the column number
  • : -- skip the colon
  • \ -- skip the space again
  • %m -- match the error message
  • , -- new line
  • %-G%.%# -- skip all the others

It runs the jslint which shows the messages but the :clist command does not show any errors.

What am I missing?

Was it helpful?

Solution

The problem was with the \,, the skip comma, the correct format is:

CompilerSet errorformat=
    \%*[\ ]%n\ %l%.%c:\ %m,
    \%-G%.%#

OTHER TIPS

The comma must be escaped with \\, since , is a special char in errorformat, and \ is a special char in vim config file, which must itself be escaped. To vim, your error format is then %*[ ]%n %l\,%c: %m,%-G%.%#, since the \ at the beginning of the line or before spaces are escapes for vim, not for the error format.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top