I have been using the the vim integrated make command to help with my build, fix, repeat cycle at work. We are in the process of moving to a new build system that I can easily change to using makeprg.
The problem is the new build system copies off the source code to a sandbox location before it builds, so when I get compile errors, vim opens up the copied file. I end up changing this copied file, and not the actual file in the main code path.
Is some way I can fix this by somehow telling vim what my code base path is?
There are at least three strategies you could use to fix this, unfortunately they’ll all involve a bit more work than just telling vim a “code base path”. Before choosing one, I’d recommend reading
:help make_makeprgto get a good sense of the:makeprocess “under the hood”.Write a shell/perl/ruby/whatever script that filters the output from your build process and rewrites file names from
/sandbox/src/blah.ctosrc/blah.cor/sandbox/srctosrcas appropriate. Then changemakeprgto include the filter program when runningmake(in your.vimrc, add this::set makeprg=make\ \\\|\ filter). This is probably pretty easy to do, but might be made trickier depending on what exact build system you are using.Change
errorformat(see:help errorformat) to strip off the sandbox prefix for you. This might not be possible in some cases, depending on the exact output format from your build system.Add a
QuickFixCmdPostautocommand that will rewrite the file paths in the quickfix window before you begin using:cnextand friends. If you haven’t used Vim’s autocommand feature before, I would try the other two strategies first. They are powerful and very useful, but they take some practice to get right.