Skip to content

Commit d5e66e0

Browse files
committed
cli: add gvimdiff merge tool, fix docs for diff-invocation-mode
The tool defaults to file-by-file diffing. Fixes jj-vcs#6206.
1 parent 5ca7dca commit d5e66e0

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

cli/src/config/merge_tools.toml

+19
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,25 @@ edit-args = [
6161
'echomsg "Warning: using plain `vimdiff` as a diff editor is not recommended. See https://github.com/jj-vcs/jj/wiki/Vim for alternatives."',
6262
"-c", "echohl None",
6363
]
64+
# Not configuring diff-args, as they currently don't seem to work (see
65+
# https://github.com/jj-vcs/jj/issues/6206)
66+
67+
[merge-tools.gvimdiff]
68+
program = "gvim"
69+
# `-d` enables diff mode. `-f` makes vim run in foreground even if it starts a GUI.
70+
# The other options make sure that only the output file can be modified.
71+
merge-args = ["-f", "-d", "$output", "-M", "$left", "$base", "$right",
72+
"-c", "wincmd J", "-c", "set modifiable", "-c", "set write",
73+
"-c", "/<<<<<</+2"]
74+
merge-tool-edits-conflict-markers = true
75+
# Directory diffing is barely usable in vimdiff without additional plugins
76+
edit-args = [
77+
"-f", "-d", "$left", "$right", "-c", "echohl WarningMsg", "-c",
78+
'echomsg "Warning: using plain `vimdiff` as a diff editor is not recommended. See https://github.com/jj-vcs/jj/wiki/Vim for alternatives."',
79+
"-c", "echohl None",
80+
]
81+
diff-invocation-mode="file-by-file"
82+
diff-args = ["-f", "-d", "$left", "$right"]
6483

6584
# if you change the settings for vscode, please do the same for vscodium
6685
[merge-tools.vscode]

docs/config.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -283,16 +283,18 @@ diff-args = ["--color=always", "$left", "$right"]
283283
- `$left` and `$right` are replaced with the paths to the left and right
284284
directories to diff respectively.
285285

286-
By default `jj` will invoke external tools with a directory containing the left
287-
and right sides. The `diff-invocation-mode` config can change this to file by file
288-
invocations as follows:
286+
By default `jj` will invoke most external tools with a directory containing the left
287+
and right sides.
288+
289+
For diff tools, the `diff-invocation-mode` config can be used to toggle between
290+
this behavior and file-by-file invocations:
289291

290292
```toml
291293
[ui]
292-
diff.tool = "vimdiff"
294+
diff.tool = "gvimdiff"
293295

294296
[merge-tools.vimdiff]
295-
diff-invocation-mode = "file-by-file"
297+
diff-invocation-mode = "dir" # Or "file-by-file"
296298
```
297299

298300
By default `jj` will display a warning when the command exits with a non-success

0 commit comments

Comments
 (0)