Reputation: 1796
I'm trying to configure vimdiff as a git merge tool, so my global git config contains the following lines:
[merge]
tool = gvimdiff
guitool = gvimdiff
[mergetool]
prompt = true
[mergetool "gvimdiff"]
layout = "LOCAL,MERGED,REMOTE"
but I am keep in having the default layout. A similar problem has reported here but it won't apply to my case because of the following reasons:
How should I solve it? Running on MacOsX Ventura.
Upvotes: 3
Views: 122
Reputation: 1329822
That should be fixed with Git 2.45 (Q2 2024), batch 2: variants of vimdiff learned to honor mergetool.<variant>.layout
settings.
See commit b21d164 (17 Feb 2024) by Kipras Melnikovas (kiprasmel
).
(Merged by Junio C Hamano -- gitster
-- in commit 66b1160, 27 Feb 2024)
mergetools
: vimdiff: use correct tool's name when reading mergetool configSigned-off-by: Kipras Melnikovas
The
/mergetools/vimdiff
script, which handles bothvimdiff
,nvimdiff
andgvimdiff
mergetools (the latter 2 simply source thevimdiff
script), has a functionmerge_cmd()
which read the layout variable fromgit config
(man), and it would always read the value ofmergetool.**vimdiff**.layout
, instead of the mergetool being currently used (vimdiff
ornvimdiff
orgvimdiff
).It looks like in 7b5cf8b ("
vimdiff
: add tool documentation", 2022-03-30, Git v2.37.0-rc0 -- merge), we explained the current behavior inDocumentation/config/mergetool.txt
:The vimdiff backend uses this variable to control how its split windows look like. Applies even if you are using Neovim (`nvim`) or gVim (`gvim`) as the merge tool. See BACKEND SPECIFIC HINTS section
which makes sense why it's explained this way - the vimdiff backend is used by gvim and nvim.
But the mergetool's configuration should be separate for each tool, and indeed that's confirmed in same commit atDocumentation/mergetools/vimdiff.txt
:## Variants Instead of `--tool=vimdiff`, you can also use one of these other variants: * `--tool=gvimdiff`, to open gVim instead of Vim. * `--tool=nvimdiff`, to open Neovim instead of Vim. When using these variants, in order to specify a custom layout you will have to set configuration variables `mergetool.gvimdiff.layout` and `mergetool.nvimdiff.layout` instead of `mergetool.vimdiff.layout`
So it looks like we just forgot to update the 1 part of the
vimdiff
script that read the config variable.
Cheers.Though, for backward compatibility, I've kept the
mergetool.vimdiff
fallback, so that people who unknowingly relied on it, won't have their setup broken now.
git config
now includes in its man page:
mergetool.<vimdiff variant>.layout
Configure the split window layout for vimdiff's
<variant>
, which is any ofvimdiff
,nvimdiff
,gvimdiff
. Upon launchinggit mergetool
with--tool=<variant>
(or without--tool
ifmerge.tool
is configured as<variant>
), Git will consultmergetool.<variant>.layout
to determine the tool's layout.If the variant-specific configuration is not available,
vimdiff
's is used as fallback.
If that too is not available, a default layout with 4 windows will be used.To configure the layout, see the
BACKEND SPECIFIC HINTS
section of git-mergetool.
mergetools/vimdiff
now includes in its man page:
mergetool.nvimdiff.layout
instead ofmergetool.vimdiff.layout
(though the latter will be used as fallback if the variant-specific one is not set).
Upvotes: 1