I am trying to set errorformat=...
so that I can parse errors like the following:
error: cannot format /home/user/repo/src/file1.py: Cannot parse: 2:5: some source code here
error: cannot format /home/user/repo/src/file2.py: Cannot parse: 7:10: some_more source code here
Oh no! ๐ฅ ๐ ๐ฅ
2 files failed to reformat.
(For context, this error is produced by the python black code formatter. I am writing CompilerSet makeprg=black
and CompilerSet errorformat=...
in the file ~/.vim/compiler/black.vim
, for use with the vim-dispatch plugin).
My question is about how to set errorformat
so that the output in the quickfix window contains all the relevant pieces of information. Ideally, all of the following should be printed in the quickfix window:
cannot format
Cannot parse
source code...
I've had some success with setting
errorformat=error:\ cannot\ format\ %f:\ %s:\ %l:%c:\ %m
which results in the following quickfix output:
file1.py|2 col 5| some source code here
file2.py|7 col 10| some_more source code here
|| Oh no! ๐ฅ ๐ ๐ฅ
|| 2 files failed to reformat.
I have also tried
errorformat=error:\ cannot\ format\ %f:\ %m:\ %l:%c:\ %s
which results in
file2.py|7 col 10| Cannot parse
file1.py|2 col 5| Cannot parse
|| Oh no! ๐ฅ ๐ ๐ฅ
|| 2 files failed to reformat.
Ideally, the quickfix output should look something like this:
file2.py|7 col 10| cannot format: Cannot parse: some source code here
file1.py|2 col 5| cannot format: Cannot parse: some_more source code here
|| Oh no! ๐ฅ ๐ ๐ฅ
|| 2 files failed to reformat.
Printing this additional information would be useful to me in quickly debugging the problem(s) in the quickfix list.
I've tried variations on using multiple %m
and %s
symbols; all of the following give errors:
error:\ cannot\ format\ %f:\ %m:\ %l:%c:\ %m
error:\ cannot\ format\ %f:\ %s:\ %l:%c:\ %s
error:\ %m\ %f:\ %m:\ %l:%c:\ %m
Any ideas?
:cnext
with the above. Vim jumps to the correct file but not to the correct line-number. Not sure if it's related to the errorformat...