Vim errorformat multiline string

844 views Asked by At

I'm trying to parse this error output for Flow. In the first error, it's the second file and line number that really matters, not the first. I would like to tell vim to use the second file entry. (So in this case, the location list should jump to source.js line 94, not line 20)

/Users/asdf/source.js:20:22,34:1: property hidden
Property not found in
/Users/asdf/source.js:94:10,106:3: object literal

/Users/asdf/source.js:25:14,18: identifier strin
Could not resolve name

Here's the error format currently defined for flow: It works except that it uses the first filename instead of the second.

let errorformat =
    \ '%f:%l:%c:%n: %m,' .
    \ '%f:%l:%c: %m'

Attempted Solution

I've been trying to use multi-line error formats, but I don't know what I'm doing. After reading :help errorformat, it seems like something like this should work, but it just loads the whole error into the message, with no file / line information. It also matches the second error using the first entry rather than the third.

let errorformat =
    \ '%E%m,%C%m,%Z%f:%l:%c:%n: %m,' .
    \ '%f:%l:%c:%n: %m,' .
    \ '%f:%l:%c: %m'

Update

Thanks to lcd047, who pointed out that I'm not matching the correct output. Syntastic formats the error as follows, all on one line:

/Users/seanhess/projects/serials/web/app/model/source.js:20:22: property hidden Property not found in object literal (/Users/seanhess/projects/serials/web/app/model/source.js:94:10,106:3)

So, new question, how can I match the second location instead of the first? I think I'd prefer to ignore the first location.

Update Answer - this worked:

let errorformat =
    \ '%.%#: %m (%f:%l:%c\,%.%#),' .
    \ '%f:%l:%c:%n: %m,' .
    \ '%f:%l:%c: %m'
1

There are 1 answers

5
David Harrison On BEST ANSWER

You are not getting the file/line information because the %E specifies to use the rest of the line as the beginning of a multi-line message.

Try changing the "%Em" to "%E%f:%l:%c:%n: %m" for starters, since you basically want to keep all the original data being grabbed from the first version of errorformat.

You may want to change the "%Cm" to "%+Cm" to capture all of the lines in your error output.

The "%Z%f:%l:%c:%n: %m" looks good and should be used on the second line, since the %E will catch the first one.

Try that.