如何为Neovim正确配置Git Mergetool?

发布于 2025-02-14 00:10:48 字数 1569 浏览 1 评论 0原文

我正在尝试将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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

因为看清所以看轻 2025-02-21 00:10:48

我遇到了同样的问题,即使用NVIMDIFF时没有应用布局。事实证明,在配置布局时,您需要使用vimdiff而不是nvimdiff。 docs

[mergetool "vimdiff"]
    layout = LOCAL,MERGED,REMOTE

I 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 of nvimdiff when configuring the layout. The docs git-mergetool detail that vim and nvim use the same layout config.

[mergetool "vimdiff"]
    layout = LOCAL,MERGED,REMOTE
迟月 2025-02-21 00:10:48

这将产生所需的结果:

[mergetool "nvimdiff"]
  layout = "LOCAL,BASE,REMOTE / MERGED"

在要点上找到: https://gist.github.com/pagliacii/8fcb4dc64937305c19df9bb3137e4cad

This will produce the desired result:

[mergetool "nvimdiff"]
  layout = "LOCAL,BASE,REMOTE / MERGED"

Found on a Gist: https://gist.github.com/Pagliacii/8fcb4dc64937305c19df9bb3137e4cad

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文