neovim as git diff and merge tool

Posted on 08 February 2015 in vim

You've made the switch. You are now using neovim for all your text editing, and you've hardly even noticed that you aren't using regular old vim. Except one thing. Your git difftool and mergetool aren't quite right. One of two things is happening. Either you are using old vim (which is fine, but you want to switch completely to neovim) or things are breaking because you have gone so far as to not just install neovim but to also remove vim!

So why is this happening? Your git mergetool is still set to vim even though you set your core.editor to nvim. So, we just tell git to use nvim for your mergetool.

First, you probably have or want something like this:

git config --global merge.tool vimdiff

Note that vimdiff in there is not the vimdiff executable. It refers to a built-in script. There's also vimdiff2 and vimdiff3. (3 is the best by the way.) Those built-in scripts call the merge_tool_path executable. Which will be set to vim by default. You can change that with

git config --global mergetool.path nvim

All done. The difftool uses the mergetool by default so that's all you need to set!