-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnvim-diff.sh
executable file
·79 lines (61 loc) · 1.83 KB
/
nvim-diff.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
#shellcheck disable=SC2016
# Show defaults differences between vim and nvim
# except those handled by my .vimrc.
# This is used to maintain .vimrc
# to set vim defaults similar to nvim defaults.
has() { command -v "$@" >/dev/null 2>&1; }
# fedora
if has vimx && ! has vim; then
vim() { vimx "$@"; }
fi
cleanit() {
cat "$1" | sed -r '
# no=off
s/^no(.*)/\1=off/;
s|^ *||;
# Remove system paths
/^(packpath|runtimepath)=/ {
s|/etc/xdg/nvim(/after)?,||g;
s|/usr/(local/)?share/n?vim(/vimfiles)?(/vim82)?(/runtime)?(/site)?(/after)?,||g;
s|/usr/lib/n?vim,||g;
s|[^,]*flatpak[^,]*,||g;
s|[^,]*matchit[^,]*,||g;
}
# path differences
s|/tmp/\.mount_nvim[^/]*/|/|g;
s|/vimswap|/swap|;
s|/vimundo|/undo|;
s|^(shadafile)=$|\1=~/.local/share/nvim/shada/main.shada|;
# Naming differences
s|main\.shada|viminfo|g;
s|shada|viminfo|g;
# option values not in both
/^cpoptions=/ { s/_//; };
/^diffopt=/ { s/,closeoff//; };
/^display=/ { s/,msgsep//; };
/^sessionoptions=/ { s/,terminal//; };
# incomparable differences
/^mouse=/ { s/=a/=/; };
/^scroll=/ d;
/^cdpath=/ d;
# do not care
/^highlight=/ d;
/^printexpr=/ d;
/^helpfile=/ d;
# Neovim has an odd default for backupdir
s/(backupdir=)\.,/\1/;
' | sort
}
# only include options that exist in both
cleaned() {
cleanit "$1" | grep -f <(cleanit "$2" | sed -r 's/=.*$//; /^$/d; s/^/^/; s/$/\\b/;')
# this isn't efficient, but who cares?
}
vim -u NONE -c 'source plugin/.vimrc' \
+'redir! > /tmp/vs.txt | silent set! all | redir END | qa'
nvim -u NONE \
+'redir! > /tmp/ns.txt | silent set! all | redir END | qa'
diff -u0 <(cleaned /tmp/vs.txt /tmp/ns.txt) <(cleaned /tmp/ns.txt /tmp/vs.txt) | \
sed '1,2 d; /^@@/d;'
rm -f /tmp/vs.txt /tmp/ns.txt