1

If I use the color logging for maven, the file path is corrupted by the coloring syntax:

^[[1;31m[ERROR]^[[m /home/foo/bar/src/main/java/com/domain/bar/App.java

instead of

[ERROR] /home/foo/bar/src/main/java/com/domain/bar/App.java:[48,50] cannot find symbol

How can I have a colored output and correct path for the quickfix window?

I use http://www.aheritier.net/united-colors-of-maven/ to have colored output.

  • I have the same issue using github.com/jcgay/maven-color – Ôrel Mar 25 '16 at 16:27
  • Can pipe the data through something like col -b to remove the color escape codes? – Peter Rincker Mar 25 '16 at 19:45
  • I would like to have the color during the build, color can be remove by MAVEN_OPTS="$MAVEN_OPTS -Dmaven.color=false". When I build C I have no issue with the color. – Ôrel Mar 25 '16 at 20:37
2

Vim does not support Ansi escape color codes. The AnsiEsc.vim plugin attempts to fix this for some cases. However I doubt AnsiEsc can be combined with the quickfix list in any meaningful way.

I suggest you remove the color from your maven output so you can use the quickfix functionality like :cnext/:cprev. Here is a simple 'errorformat' value for maven 3:

set errorformat=[ERROR]\ %f:[%l\\,%v]\ %m

For more help see:

:h :make
:h 'makeprg'
:h 'errorformat'
:h errorformat
:h quickfix
| improve this answer | |
1

My solution to have color working into vim and console is to use https://github.com/jcgay/maven-color

Then set the colored log pattern into /opt/apache-maven-3.3.9/conf/logging/log4j2.xml

<Console name="maven-color-true" target="SYSTEM_OUT">
  <PatternLayout pattern="%highlight{[%p] %mavenMsg%n%rEx}{FATAL=red, ERROR=red, WAR>
</Console>

The tips is to keep the leading [ERROR] using [%p] into the pattern.

Then into maven-compiler.vim/compiler/mvn.vim (thanks @Peter Rincker)

CompilerSet errorformat+=%E%.%#[ERROR]\ %f:[%l\\,%c]\ %m,%Z

or the solution is to have color for console and into vim deactivate color in maven-compiler.vim/compiler/mvn.vim:

CompilerSet makeprg=MAVEN_OPTS=\"$MAVEN_OPTS\ -Dmaven.color=false\"\ mvn
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.