-
Notifications
You must be signed in to change notification settings - Fork 102
/
setup.sh
executable file
·132 lines (122 loc) · 3.8 KB
/
setup.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/usr/bin/env bash
help() {
echo "setup.sh -- setup ivim"
echo "Usage: setup.sh -i|-m|-u|-n"
echo "-i -- install ivim"
echo "-m -- install ivim_mini for vim"
echo "-u -- install ivim_mini for neovim"
echo "-n -- update ivim"
exit 0
}
color_print() {
printf '\033[0;31m%s\033[0m\n' "$1"
}
warn() {
color_print "$1" >&2
}
die() {
warn "$1"
exit 1
}
logo() {
color_print "Thank you for installing ivim!"
color_print ' _ _ '
color_print ' (_) __(_)___ ___ '
color_print ' / / | / / / __ `__ \'
color_print ' / /| |/ / / / / / / /'
color_print '/_/ |___/_/_/ /_/ /_/ '
color_print ' '
}
require() {
color_print "Checking requirements for ivim..."
if [ $1 = 0 ]; then
color_print "Checking Vim version..."
vim --version | grep -E 7.[3-9]\|8.[0-9] || die "Your vim's version is too low!\nPlease download higher version(7.3+) from http://www.vim.org/download.php"
elif [ $1 = 1 ]; then
color_print "Checking Vim version..."
vim --version | grep -E 8.[0-9] || die "Your vim's version is too low!\nPlease download higher version(8.0+) from http://www.vim.org/download.php"
else
color_print "Checking NeoVim version..."
nvim --version || die "Please install NeoVim according to https://github.com/neovim/neovim/wiki/Installing-Neovim"
fi
color_print "Checking if git exists..."
which git || die "No git installed!\nPlease install git from http://git-scm.com/downloads/"
color_print "Check if ctags exists..."
which ctags || warn "No ctags installed!\nPlease install ctags form http://ctags.sourceforge.net/ after ivim intallation!"
}
install() {
color_print "Cloning ivim..."
cd $HOME
rm -rf $HOME/.ivim
git clone https://github.com/kepbod/ivim.git $HOME/.ivim
if [ $1 = 0 ]; then
ln -s $HOME/.ivim/vimrc $HOME/.vimrc
elif [ $1 = 1 ]; then
ln -s $HOME/.ivim/vimrc_mini $HOME/.vimrc
else
mkdir -p $HOME/.config/nvim
ln -s $HOME/.ivim/vimrc_mini $HOME/.config/nvim/init.vim
fi
color_print "Installing vim-plug..."
if [ $1 = 2 ]; then
curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
else
curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
fi
color_print "Installing colortheme..."
if [ $1 = 0 ]; then
git clone https://github.com/kristijanhusak/vim-hybrid-material.git $HOME/.vim/bundle/vim-hybrid-material
elif [ $1 = 1 ]; then
git clone https://github.com/arcticicestudio/nord-vim.git $HOME/.vim/plugged/nord-vim
else
git clone https://github.com/arcticicestudio/nord-vim.git $HOME/.config/nvim/plugged/nord-vim
fi
color_print "Installing plugins using vim-plug..."
if [ $1 = 2 ]; then
nvim +PlugUpdate +qal
else
vim +PlugUpdate +qal
fi
color_print "ivim has been installed. Just enjoy vimming!"
}
update() {
color_print "updating ivim..."
cd $HOME/.ivim
git pull origin master
color_print "updating plugins..."
if [ -e $HOME/.config/nvim/init.vim ]; then
nvim +PlugClean! +PlugUpdate +qal
fi
if [ -e $HOME/.vimrc ]; then
vim +PlugClean! +PlugUpdate +qal
fi
}
if [ $# -ne 1 ]; then
help
fi
while getopts ":imun" opts; do
case $opts in
i)
logo
require 0
install 0
;;
m)
logo
require 1
install 1
;;
u)
logo
require 2
install 2
;;
n)
update
;;
:)
help;;
?)
help;;
esac
done