5

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!

4

2 回答 2

6

由于您正在操作该'makeprg'选项,无论如何,我将添加一个自定义过滤器(例如 with sed),将远程文件规范转换为本地安装点,如下所示:

:set makeprg=ssh\ mylinuxmachine\ \"make\ -C\ repos/myproject\"\|sed\ \"s#/home/myuser#/net/mylinuxmachine/home/myuser#g\"
于 2013-10-08T08:03:21.803 回答
2

知道了。Ingo 把我推向了正确的方向。

在实验过程中,我厌倦了所有的转义,所以我创建了以下小 shellscript:

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

这将调用make -C给定的项目目录,合并 stdout 和 stderr(因为错误消息通过 stderr 出现)并将其通过管道传输到 sed 中,这将简单地删除错误消息中的绝对路径(这将导致受影响的只是相对路径来自项目根目录的文件——我的密码通常在 vim 中)。

然后我设置makeprg为我要构建的项目执行脚本:

:set makeprg=./makeprg.sh\ myproject

现在就像一个魅力!

谢谢

于 2013-10-08T10:01:14.070 回答