-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·110 lines (94 loc) · 2.9 KB
/
install.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
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
#!/bin/bash
#
# Vim configuration with Go in mind.
# This setup uses mostly symlinks, so as to
# make vim plugin repos easy to update.
VIMHOME="$HOME/.vim"
# All source code will be cloned here
REPOS=$1
EARGS=50
EPATH=51
ETOOLS=52
function usage()
{
echo "
Usage: install.sh /PATH/TO/REPO
REPO Absolute path where all dowloaded code will be saved."
exit $1
}
# check for repo directory argument
if [ -z $REPOS ]; then
usage $ARGS
fi
# check if $REPO is absolute
if [ ! ${REPOS%%/*} == "/" ]; then
echo -e "$REPOS is not an absolute path\n"
usage $EPATH
fi
# check for Go
go version &> /dev/null
if [ ! $? -eq 0 ]; then
echo -e "Go language support is required\n"
usage $ETOOLS
fi
# check for GOROOT
if [ -z $GOROOT ]; then
echo -e "Please set the GOROOT environment variable"
usage $ETOOLS
fi
# backup old vim-configs before running scripts
[ -f ${HOME}/.vimrc ] && mv ${HOME}/.vimrc{,.old}
cp -v vimrc ${HOME}/.vimrc
[ -d ${HOME}/.vim ] && mv ${HOME}/.vim{,.old}
# install pathogen.vim to manage runtimepath
# vimrc contains configuration to activate.
PLUGIN='github.com/tpope/vim-pathogen'
AUTHOR=${PLUGIN%/*}
TOOL=${PLUGIN##*/}
git clone git://$PLUGIN.git || exit $?
mkdir -pv $REPOS/$AUTHOR && mv $TOOL $REPOS/$AUTHOR
mkdir -pv $VIMHOME/autoload $VIMHOME/bundle
ln -sv $REPOS/$PLUGIN/autoload/pathogen.vim \
$VIMHOME/autoload/pathogen.vim
rm -rf $TOOL
# With pathogen.vim setup we can now install all plugins into the bundle
# directory.
# install Go's standard vim plugins, ttousai/vim-config/plugin/go.vim
# we assume vim-config is already in $REPOS
# also this script is in vim-config so we
# can assume you already got it.
PLUGIN='github.com/ttousai/vim-config'
ln -sv $REPOS/$PLUGIN $VIMHOME/bundle/${PLUGIN##*/}
# install gotags
PLUGIN='github.com/jstemmer/gotags'
go get -u $PLUGIN || exit $?
# install nsf/gocode assumes go is install and GOPATH properly configured
# configuration for "tagbar" support installed later is in vim-config/plugin/go.vim
PLUGIN='github.com/nsf/gocode'
go get -u $PLUGIN || exit $?
ln -sv $GOPATH/src/$PLUGIN/vim/ $VIMHOME/bundle/${PLUGIN##*/}
# the following share same installation code
plugins=(\
'scrooloose/nerdtree' 'ervandew/supertab'\
'majutsushi/tagbar' 'Townk/vim-autoclose'\
'tpope/vim-sensible' 'altercation/vim-colors-solarized'\
'scrooloose/syntastic'\
)
for p in ${plugins[@]}; do
# install plugin using pathogen.vim
PLUGIN="github.com/$p"
AUTHOR=${PLUGIN%/*}
TOOL=${PLUGIN##*/}
git clone git://$PLUGIN.git || exit $?
mkdir -pv $REPOS/$AUTHOR && mv $TOOL $REPOS/$AUTHOR
ln -sv $REPOS/$PLUGIN $VIMHOME/bundle/$TOOL
rm -rf $TOOL
done
# install Conque for vim in-band shell
PLUGIN="code.google.com/p/conque"
TOOL="conque"
svn checkout http://conque.googlecode.com/svn/trunk/ $TOOL
ln -sv $REPOS/$PLUGIN $VIMHOME/bundle/$TOOL
# install vimrc, and templates.
# support for templating is in vim-config/plugin/default.vim
cp -av templates ${HOME}/.vim