Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim quickfix and remote compilation

Tags:

vim

I have a linux machine that I use for building my project (c++/make). I have the project directory mounted on my mac machine in which I do the editing using macvim.

I managed to set the makeprg setting so that :make will issue a remote compilation on my linux machine. However, I would also like to use vim's quickfix feature. The only problem I have is that the filepaths don't match up.

e.g. on the remote machine, the source and makefile resides in ~/repos/myproject which in my mac is mounted to /net/mylinuxmachine/home/myuser/repos/myproject. This results in vim not correctly opening the affected file in case of a compilation error there.

I've set my makeprg like this:

:set makeprg=ssh\ mylinuxmachine\ \"make\ -C\ repos/myproject\"

Is there anything I can do to make this work?

thanks in advance!

like image 615
DeX3 Avatar asked Oct 08 '13 07:10

DeX3


2 Answers

Since you're manipulating the 'makeprg' option, anyway, I would add a custom filter (e.g. with sed) that converts the remote filespec to the local mount point, like this:

:set makeprg=ssh\ mylinuxmachine\ \"make\ -C\ repos/myproject\"\|sed\ \"s#/home/myuser#/net/mylinuxmachine/home/myuser#g\"
like image 135
Ingo Karkat Avatar answered Nov 04 '22 00:11

Ingo Karkat


Got it. Ingo pushed me in the right direction.

During experimenting I got tired of all the escaping, so I created the following little shellscript:

project=$1
ssh mylinuxmachine "make -C repos/$myproject" 2>&1 | sed "s#/home/myuser/repos/$project/##g"

This will call make -C on the given project directory, merge stdout and stderr (since error messages come out via stderr) and pipe that into sed which will simply remove the absolute path in the error messages (which will result in just the relative path to the affected file from the projects base root - where my pwd usually is within vim).

Then I set makeprg to the execute the script with the project I want to build:

:set makeprg=./makeprg.sh\ myproject

Works like a charm now!

thanks

like image 25
DeX3 Avatar answered Nov 03 '22 22:11

DeX3