I have a project where make and vim are run from different directories. The project structure looks like this:

  ├── build
  │   └── gmake_linux
  │       ├── bin
  │       │   └── Debug
  │       └── obj
  │           └── Debug
  ├── include
  ├── source
  ├── test

I use the project root as my working directory for everything, including a custom Makefile. However, the "real" build work is done two levels down in the build/gmake_linux directory. The heavy-lifting is done by Makefiles generated by premake5.

Because of this, messages containing filenames tend to contain a bunch of extra ../.., like so:

==== Building run_tests (debug) ====
make[1]: Leaving directory '/home/aghast/Code/aghast /libaghast/build/gmake_linux'
[1646719388.628151980] Running tests...
../../source/bytes.c:72: Unittest failed in unittest_ba_compare_lt
  ba_compare(ba1, ba2) < 0

So when I invoke something like :make or :make test, I get bad handling of the resulting files.

Is there some clever way to fix up the source paths so that Vim can process them correctly?

  • Not relevant at all, but are you guys making those diagrams from scratch or is there a handy shortcut I'm missing?
    – Joe
    Mar 8 at 7:28
  • On linux, man tree. I replaced the content lines with colon (':') characters myself.
    – aghast
    Mar 8 at 9:57
  • 1
    You could have a look at the %D and %X specifiers for errorformat (:help E379). Or get your compiler to print absolute paths. Otherwise you could use an autocommand on QuickFixCmdPost and manipulate getqflist() and setqflist().
    – D. Ben Knoble
    Mar 8 at 14:51


Your Answer

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

Browse other questions tagged or ask your own question.