diff mbox series

Support nvim as mergetool

Message ID 20200718192001.27434-1-rogi@skylittlesystem.org (mailing list archive)
State New, archived
Headers show
Series Support nvim as mergetool | expand

Commit Message

pudinha July 18, 2020, 7:20 p.m. UTC
---
Hello giters! Hope you are well!

I made this little patch to support nvim as a merge tool. What do you
think?

Best regards,
Pudinha <3

 mergetools/nvimdiff  | 1 +
 mergetools/nvimdiff2 | 1 +
 mergetools/nvimdiff3 | 1 +
 mergetools/vimdiff   | 9 ++++++---
 4 files changed, 9 insertions(+), 3 deletions(-)
 create mode 100644 mergetools/nvimdiff
 create mode 100644 mergetools/nvimdiff2
 create mode 100644 mergetools/nvimdiff3

Comments

Junio C Hamano July 18, 2020, 8:30 p.m. UTC | #1
pudinha <rogi@skylittlesystem.org> writes:

> ---
> Hello giters! Hope you are well!
>
> I made this little patch to support nvim as a merge tool. What do you
> think?

Uninspiring.

But that is not your fault.  

The way vimdiff, vimdiff2 and vimdiff3 waste one file for each just
to have a different name is simply bad, and the way it was extended
to cover gvimdiff family is even more horrible.  This patch makes
the existing mess even worse.  That part is your fault, I'd have to
say.

I'd rather see us explore ways to improve the current arrangement
used to support these 6 variants before adding yet another 3 new
ones.

For example, we could add another method the backends could define,
call it list_tool_variants, and whenever the control flow goes from
run_merge_tool through setup_tool for a tool whose name ends with
[1-9], e.g. "foomerge3", we first see if there is "foomerge" tool
and if there is ask it if it knows about "foomerge3" variant by
calling its list_tool_variants.

That way, we probably can remove the files for vimdiff2, vimdiff3,
gvimdiff2 and gvimdiff3 (gvimdiff needs to stay there, as we do not
want to make the name derivation rule too complex) only to hold a
single line ". vimdiff".  Then the next person who adds yet another
set of backends based on a yet another reimplementation or skin of
vim would only have to add a single file in mergetools/ directory,
not three.

Hmm?
diff mbox series

Patch

diff --git a/mergetools/nvimdiff b/mergetools/nvimdiff
new file mode 100644
index 0000000000..04a5bb0ea8
--- /dev/null
+++ b/mergetools/nvimdiff
@@ -0,0 +1 @@ 
+. "$MERGE_TOOLS_DIR/vimdiff"
diff --git a/mergetools/nvimdiff2 b/mergetools/nvimdiff2
new file mode 100644
index 0000000000..04a5bb0ea8
--- /dev/null
+++ b/mergetools/nvimdiff2
@@ -0,0 +1 @@ 
+. "$MERGE_TOOLS_DIR/vimdiff"
diff --git a/mergetools/nvimdiff3 b/mergetools/nvimdiff3
new file mode 100644
index 0000000000..04a5bb0ea8
--- /dev/null
+++ b/mergetools/nvimdiff3
@@ -0,0 +1 @@ 
+. "$MERGE_TOOLS_DIR/vimdiff"
diff --git a/mergetools/vimdiff b/mergetools/vimdiff
index 10d86f3e19..be559062ee 100644
--- a/mergetools/vimdiff
+++ b/mergetools/vimdiff
@@ -5,7 +5,7 @@  diff_cmd () {
 
 merge_cmd () {
 	case "$1" in
-	gvimdiff|vimdiff)
+	nvimdiff|gvimdiff|vimdiff)
 		if $base_present
 		then
 			"$merge_tool_path" -f -d -c '4wincmd w | wincmd J' \
@@ -15,11 +15,11 @@  merge_cmd () {
 				"$LOCAL" "$MERGED" "$REMOTE"
 		fi
 		;;
-	gvimdiff2|vimdiff2)
+	nvimdiff2|gvimdiff2|vimdiff2)
 		"$merge_tool_path" -f -d -c 'wincmd l' \
 			"$LOCAL" "$MERGED" "$REMOTE"
 		;;
-	gvimdiff3|vimdiff3)
+	nvimdiff3|gvimdiff3|vimdiff3)
 		if $base_present
 		then
 			"$merge_tool_path" -f -d -c 'hid | hid | hid' \
@@ -34,6 +34,9 @@  merge_cmd () {
 
 translate_merge_tool_path() {
 	case "$1" in
+	nvimdiff|nvimdiff2|nvimdiff3)
+		echo nvim
+		;;
 	gvimdiff|gvimdiff2|gvimdiff3)
 		echo gvim
 		;;