forked from luan/vimfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·151 lines (126 loc) · 3.12 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/usr/bin/env bash
print_usage() {
echo -e "Unsupported option: $@"
echo -e "Supported options:"
echo -e "\t-u, --update \tUpdate all plugins."
echo -e "\t-n, --non-interactive \tDon't show vim while installing plugins."
}
INTERACTIVE=1
UPDATE=0
while [[ $# > 0 ]]
do
key="$1"
case $key in
-n|--non-interactive)
INTERACTIVE=0
shift
;;
-u|--update)
UPDATE=1
shift
;;
*)
print_usage $key
exit 1
;;
esac
shift
done
FILES_TO_LINK="vimrc gvimrc"
LOCALS=".vimrc.local.before .vimrc.local .vimrc.local.plugins"
DIR=$(cd $(dirname $0) && pwd)
if [ $(basename $DIR) == "bin" ]; then
DIR=$(cd ${DIR}/.. && pwd)
fi
if [ "$DIR" != "$HOME/.vim" ]; then
dot_file=$HOME/.vim
if [ ! -e $dot_file ]; then
echo "Detected clone outside of ~/.vim, symlinking"
ln -s $DIR $dot_file
fi
fi
if which nvim > /dev/null; then
mkdir -p ${XDG_CONFIG_HOME:=$HOME/.config}
if [ ! -e $XDG_CONFIG_HOME/nvim ]; then
ln -s $DIR $XDG_CONFIG_HOME/nvim
fi
fi
pushd $DIR
if [ -e $DIR/bundle ]; then
rm -rf $DIR/bundle
fi
git submodule update --init --recursive
for file in $LOCALS; do
dot_file=$HOME/$file
touch $dot_file
done
for file in $FILES_TO_LINK; do
dot_file=$HOME/.$file
if [ ! -e $dot_file ]; then
ln -s $DIR/$file $dot_file
fi
done
if [ "$(uname)" == "Darwin" ]; then
VIM_UPDATE_PATH=/usr/local/bin
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
VIM_UPDATE_PATH=$HOME/bin
fi
if [ -L $VIM_UPDATE_PATH/vim-update ]; then
rm -f $VIM_UPDATE_PATH/vim-update
fi
if [ ! -L $VIM_UPDATE_PATH/vim-update ]; then
mkdir -p $VIM_UPDATE_PATH
ln -s $DIR/bin/update $VIM_UPDATE_PATH/vim-update
fi
green='\033[0;32m'
yellow='\033[0;33m'
bold=`tput bold`
normal=`tput sgr0`
end_color='\033[0;m'
if which go > /dev/null; then
echo -e "${yellow}INSTALL${end_color} ${bold}golang${normal} dependencies..."
gopackages="\
github.com/alecthomas/gometalinter \
github.com/fatih/motion \
github.com/golang/lint/golint \
github.com/jstemmer/gotags \
github.com/kisielk/errcheck \
github.com/klauspost/asmfmt/cmd/asmfmt \
github.com/nsf/gocode \
github.com/rogpeppe/godef \
golang.org/x/tools/cmd/godoc \
golang.org/x/tools/cmd/goimports \
golang.org/x/tools/cmd/gorename \
golang.org/x/tools/cmd/oracle \
"
for p in $gopackages; do
echo -e "\t${yellow}INSTALL${end_color} ${bold}${p}${normal}..."
go get -f -u $p
echo -e "\t${green}DONE${end_color} ${bold}${p}${normal}"
done
echo -e "${green}DONE${end_color} ${bold}golang${normal} dependencies"
fi
vim +'silent! PlugClean!|' +'qall!'
if which nvim > /dev/null; then
nvim +'silent! PlugClean!|' +'qall!'
fi
vimcmd=""
if [ $UPDATE == 1 ]; then
vimcmd=$vimcmd"silent! PlugUpdate!|"
else
vimcmd=$vimcmd"silent! PlugInstall!|"
fi
vimcmd=$vimcmd"silent! GoInstallBinaries!|"
if [ $INTERACTIVE == 1 ] ; then
vim +"$vimcmd" +'qall!'
else
vim +"$vimcmd" +'qall!' > /dev/null
fi
if which nvim > /dev/null; then
if [ $INTERACTIVE == 1 ] ; then
nvim +"$vimcmd" +'qall!'
else
nvim +"$vimcmd" +'qall!' > /dev/null
fi
fi
popd