如何为Neovim正确配置Git Mergetool?
我正在尝试将Neovim用作Git Mergetool,但它无法正常工作或从文档中了解的那样。
这是我的.gitConfig
:
[user]
name = Augusto
[pull]
rebase = true
[diff]
tool = nvimdiff
guitool = nvimdiff
[merge]
tool = nvimdiff
conflictstyle = diff3
[mergetool]
keepBackup = false
trustExitCode = false
prompt = true
[difftool]
prompt = false
[commit]
gpgsign = true
[core]
editor = nvim
pager = bat
[mergetool "nvimdiff"]
layout = LOCAL,MERGED,REMOTE
当我运行git mergetool
时,它会按预期打开neovim,但没有正确的布局。它始终以默认值打开,但不用所有“文件”打开。
而不是
------------------------------------------
| | | |
| LOCAL | BASE | REMOTE |
| | | |
------------------------------------------
| |
| MERGED |
| |
------------------------------------------
像命令输出那样打开它
------------------------------------------
| | | |
| LOCAL | LOCAL | MERGED |
| | | |
------------------------------------------
| |
| LOCAL |
| |
------------------------------------------
:
git config mergetool.nvimdiff.layout
LOCAL,MERGED,REMOTE
git config merge.tool
nvimdiff
I'm trying to use neovim as git mergetool but it is not working as expected or as I understood from the documentation.
Here's my .gitconfig
:
[user]
name = Augusto
[pull]
rebase = true
[diff]
tool = nvimdiff
guitool = nvimdiff
[merge]
tool = nvimdiff
conflictstyle = diff3
[mergetool]
keepBackup = false
trustExitCode = false
prompt = true
[difftool]
prompt = false
[commit]
gpgsign = true
[core]
editor = nvim
pager = bat
[mergetool "nvimdiff"]
layout = LOCAL,MERGED,REMOTE
When I run git mergetool
, it opens NeoVim as expected, but not with the correct layout. It always opens with the default but not with all the "files" it should open.
Instead of
------------------------------------------
| | | |
| LOCAL | BASE | REMOTE |
| | | |
------------------------------------------
| |
| MERGED |
| |
------------------------------------------
It is opening like this
------------------------------------------
| | | |
| LOCAL | LOCAL | MERGED |
| | | |
------------------------------------------
| |
| LOCAL |
| |
------------------------------------------
Command outputs:
git config mergetool.nvimdiff.layout
LOCAL,MERGED,REMOTE
git config merge.tool
nvimdiff
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我遇到了同样的问题,即使用NVIMDIFF时没有应用布局。事实证明,在配置布局时,您需要使用
vimdiff
而不是nvimdiff
。 docsI had the same issue where the layout wasn't being applied when using the nvimdiff. It turns out that you need to use
vimdiff
instead ofnvimdiff
when configuring the layout. The docs git-mergetool detail that vim and nvim use the same layout config.这将产生所需的结果:
在要点上找到: https://gist.github.com/pagliacii/8fcb4dc64937305c19df9bb3137e4cad
This will produce the desired result:
Found on a Gist: https://gist.github.com/Pagliacii/8fcb4dc64937305c19df9bb3137e4cad