3

I'm using MacVim as my editor and Atlassian SourceTree (v1.5.3) as my VCS frontend. I have MacVim's command line helper script mvim installed and mvimdiff properly symlinked.

I want to use mvimdiff as a external diff tool for different kinds of VCS repositories (Git, Hg, SVN) in SourceTree.

When "External diff"ing a file/merge conflict via SourceTree, both diff windows are just empty.

Manually diffing files via mvimdiff file1 file2 works properly.

These are my settings in SourceTree: https://i.stack.imgur.com/2eQZD.png

How can i set up MacVim/gVim to work with SourceTree?

ryz
  • 131
  • 2

2 Answers2

0

Your settings in the diff configuration are almost correct, you just need to make a little adjustment to make sure that (for example) git can find the binary. In the git docs, it states that the binary (in your case mvimdiff) must be in your path or else given its full path.

That leaves you with two options, either make sure that mvimdiff exists in /usr/local/bin or /usr/bin (or some other place that is on the Mac's default path), or do what I have just done and tested: put the mvim script in a known place in your $HOME directory and reference it there with the ~ (the only expansion that git supports).

So, I have created a folder in my Home folder called .bin (with a leading dot to hide it from the Finder) and then put the mvim script in there. Then in SourceTree I have set the 'Diff Command' to

~/.bin/mvim -d

and I have set the 'Arguments' similar to what you have, but I have put them in quotes to handle files with spaces and other special characters in them, so

"$LOCAL" "$REMOTE"

NOTE: I have not tested this with hg or subversion, but since svn is supported via git-svn, it should work for subversion in that configuration too.

  • That doesn't work. For some reason SourceTree doesn't propagate $LOCAL variable to vim correctly. It's strange, it works in any other editor, but for some reason vim can't find the file and creates a new, empty one instead. I have a feeling, maybe because vim opens too fast and SourceTree can't extract source from repo to a temporary file fast enough. I don't know – iLemming Dec 16 '14 at 00:26
  • Oh actually I found the problem. For whatever reason macvim adds another slash before the filename WTF? – iLemming Dec 16 '14 at 00:54
0

You have to pass the option -f to tell MacVim not to fork a new process, but it seems that SourceTree does not pass arguments correctly.

So, to use mvimdiff, simply copy mvim as mvimdiff (instead of symlink it) and change the last but 3 line of mvimdiff from

exec "$binary" -g $opts ${1:+"$@"}

to

exec "$binary" -g -f $opts ${1:+"$@"}
L.-T. Chen
  • 381
  • 4
  • 4