Reputation: 7989
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?
Upvotes: 3
Views: 1741
Reputation: 2153
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_makeprg
to get a good sense of the :make
process "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.c
to src/blah.c
or /sandbox/src
to src
as appropriate. Then change makeprg
to include the filter program when running make
(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 QuickFixCmdPost
autocommand that will rewrite the file paths in the quickfix window before you begin using :cnext
and 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.
Upvotes: 5