This repository has been archived by the owner on Sep 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
install
executable file
·105 lines (93 loc) · 2.39 KB
/
install
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env bash
# defaults
developer=0
gvimrc=0
clean=0
nvim=0
startvimrc="vimrc"
# usage
function usage() {
echo "use: $0 [options]"
echo " -d install development config (else simpler config)"
echo " -g also install gvimrc (ignore for nvim)"
echo " -c do clean installation"
echo " -n install for nvim"
echo " -h show this usage"
exit 0
}
# process options
while getopts ":dgcnh" arg; do
case "$arg" in
d) developer=1 ;;
g) gvimrc=1 ;;
c) clean=1 ;;
n) nvim=1 ;;
h) usage ;;
*) usage ;;
esac
done
if [[ $developer -eq 1 ]]; then
startvimrc="vimrc-developer"
if command -v go > /dev/null 2>&1; then
go get -u github.com/stamblerre/gocode
fi
fi
if [[ $nvim -eq 1 ]]; then
configpath="$HOME/.config/nvim"
vimrcfile="$HOME/.config/nvim/init.vim"
gvimrcfile=""
else
configpath="$HOME/.vim"
vimrcfile="$HOME/.vimrc"
gvimrcfile="$HOME/.gvimrc"
fi
# clean current vim stuff
if [[ $clean -ne 0 ]]; then
[[ "$configpath" != "" ]] && rm -rf "$configpath"
[[ "$vimrcfile" != "" ]] && rm -f "$vimrcfile"
[[ "$gvimrcfile" != "" ]] && rm -f "$gvimrcfile"
[[ $nvim -eq 1 ]] && rm -rf "$HOME/.local/share/nvim"
fi
uname=$(uname)
if [[ "$uname" == "Linux" ]]; then
cd "$(dirname "$(readlink -f "$0")")" || exit 1
else
cd "$(cd "$(dirname "$0")"; pwd -P)" || exit 1
fi
# put the vimfiles in place
[[ ! -d "$configpath" ]] && mkdir -p "$configpath"
cp -a ./vimfiles/* "$configpath/"
# copy new vimrc
cp -a ./$startvimrc "$vimrcfile"
# copy gvimrc when requested
[[ $gvimrc -eq 1 ]] && [[ "$gvimrcfile" != "" ]] && cp -a ./gvimrc "$gvimrcfile"
if [[ $nvim -eq 1 ]]; then
nvim +PlugInstall +qall
nvim +UpdateRemotePlugins +qall
####
# Treesitter
####
nvim +'TSUpdate bash' +qall
nvim +'TSUpdate dockerfile' +qall
if command -v go > /dev/null 2>&1; then
nvim +'TSUpdate go' +qall
nvim +'TSUpdate gomod' +qall
fi
nvim +'TSUpdate perl' +qall
if [[ -e '/usr/bin/php' ]]; then
nvim +'TSUpdate php' +qall
nvim +'TSUpdate phpdoc' +qall
fi
nvim +'TSUpdate python' +qall
nvim +'TSUpdate yaml' +qall
else
vim +PlugInstall +qall
fi
if [[ $clean -eq 0 ]]; then
if [[ $nvim -eq 1 ]]; then
nvim +PlugUpdate +qall
nvim +UpdateRemotePlugins +qall
else
vim +PlugUpdate +qall
fi
fi