-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinstall.sh
executable file
·296 lines (257 loc) · 7.04 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
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
#!/bin/bash
set -e
NEOVIM_CONFIG_DIR=~/.config/nvim
NEOVIM_DIR=~/.local/share/nvim/site
# 获取linux发行版名称
function get_linux_distro()
{
if grep -Eq "Ubuntu" /etc/*-release; then
echo "Ubuntu"
elif grep -Eq "Deepin" /etc/*-release; then
echo "Deepin"
elif grep -Eq "LinuxMint" /etc/*-release; then
echo "LinuxMint"
elif grep -Eq "elementary" /etc/*-release; then
echo "elementaryOS"
elif grep -Eq "Debian" /etc/*-release; then
echo "Debian"
elif grep -Eq "Kali" /etc/*-release; then
echo "Kali"
elif grep -Eq "CentOS" /etc/*-release; then
echo "CentOS"
elif grep -Eq "fedora" /etc/*-release; then
echo "fedora"
elif grep -Eq "openSUSE" /etc/*-release; then
echo "openSUSE"
elif grep -Eq "Arch Linux" /etc/*-release; then
echo "ArchLinux"
elif grep -Eq "ManjaroLinux" /etc/*-release; then
echo "ManjaroLinux"
else
echo "Unknow"
fi
}
# 获取日期
function get_datetime()
{
time=$(date "+%Y%m%d%H%M%S")
echo $time
}
# 判断文件是否存在
function is_exist_file()
{
filename=$1
if [ -f $filename ]; then
echo 1
else
echo 0
fi
}
# 判断目录是否存在
function is_exist_dir()
{
dir=$1
if [ -d $dir ]; then
echo 1
else
echo 0
fi
}
# 获取ubuntu版本
function get_ubuntu_version()
{
line=$(cat /etc/lsb-release | grep "DISTRIB_RELEASE")
arr=(${line//=/ })
version=(${arr[1]//./ })
echo ${version[0]}
}
# 安装ubuntu必备软件
function install_prepare_software_on_ubuntu()
{
sudo apt-get install software-properties-common
echo "\n" | sudo add-apt-repository ppa:neovim-ppa/unstable
version=$(get_ubuntu_version)
if [ $version -eq 14 ];then
sudo apt-get install -y cmake3
else
sudo apt-get install -y cmake
fi
sudo apt-get install -y neovim npm exuberant-ctags build-essential fontconfig libfile-next-perl ack-grep git
# 插件需要
sudo apt-get install -y ripgrep fzf
# 安装最新版nodejs(coc.nvim要求)
sudo npm install n -g
sudo n stable
}
# 安装macOS软件
function install_prepare_software_on_mac()
{
brew install neovim gcc cmake ctags-exuberant ack node
}
# 安装ubuntu系必备软件
function install_prepare_software_on_ubuntu_like()
{
sudo apt-get update
sudo apt-get install -y cmake exuberant-ctags build-essential python python-dev python3-dev fontconfig libfile-next-perl ack-grep git
}
# 安装archlinux必备软件
function install_prepare_software_on_archlinux()
{
sudo pacman -S --noconfirm neovim ctags automake gcc cmake python3 ack git nodejs npm fontconfig
sudo ln -s /usr/lib/libtinfo.so.6 /usr/lib/libtinfo.so.5
}
# 拷贝文件
function copy_files()
{
mkdir -p ${NEOVIM_CONFIG_DIR}
rm -rf ${NEOVIM_CONFIG_DIR}/init.vim
ln -s ${PWD}/init.vim ${NEOVIM_CONFIG_DIR}
rm -rf ${NEOVIM_CONFIG_DIR}/coc-settings.json
ln -s ${PWD}/coc-settings.json ${NEOVIM_CONFIG_DIR}
rm -rf ${NEOVIM_CONFIG_DIR}/init.vim.custom.plugins
ln -s ${PWD}/init.vim.custom.plugins ${NEOVIM_CONFIG_DIR}
rm -rf ${NEOVIM_CONFIG_DIR}/init.vim.custom.config
ln -s ${PWD}/init.vim.custom.config ${NEOVIM_CONFIG_DIR}
mkdir -p ${NEOVIM_DIR}
rm -rf ${NEOVIM_DIR}/colors
ln -s ${PWD}/colors ${NEOVIM_DIR}
rm -rf ${NEOVIM_DIR}/ftplugin
ln -s ${PWD}/ftplugin ${NEOVIM_DIR}
rm -rf ${NEOVIM_DIR}/autoload
ln -s ${PWD}/autoload ${NEOVIM_DIR}
rm -rf ${NEOVIM_DIR}/lua
ln -s ${PWD}/lua ${NEOVIM_DIR}
}
# 安装mac平台字体
function install_fonts_on_mac()
{
rm -rf ~/Library/Fonts/Droid\ Sans\ Mono\ Nerd\ Font\ Complete.otf
cp ./fonts/* ~/Library/Fonts
}
# 安装linux平台字体
function install_fonts_on_linux()
{
mkdir -p ~/.local/share/fonts
rm -rf ~/.local/share/fonts/Droid\ Sans\ Mono\ Nerd\ Font\ Complete.otf
cp ./fonts/* ~/.local/share/fonts
fc-cache -vf ~/.local/share/fonts
}
# 安装vim插件
function install_vim_plugin()
{
rm -rf ~/.vim/plugged
mkdir -p ~/.vim/plugged
nvim -c "PlugInstall" -c "q" -c "q"
}
# 开始安装vimplus
function begin_install_vimplus()
{
copy_files
python3 -m pip install neovim jedi-language-server cmakelang
install_vim_plugin
}
# 在macOS上安装vimplus
function install_vimplus_on_mac()
{
install_prepare_software_on_mac
install_fonts_on_mac
begin_install_vimplus
}
# 在ubuntu上安装vimplus
function install_vimplus_on_ubuntu()
{
install_prepare_software_on_ubuntu
install_fonts_on_linux
begin_install_vimplus
}
# 在ubuntu系上安装vimplus
function install_vimplus_on_ubuntu_like()
{
backup_vimrc_and_vim
install_prepare_software_on_ubuntu_like
install_fonts_on_linux
begin_install_vimplus
}
# 在archlinux上安装vimplus
function install_vimplus_on_archlinux()
{
install_prepare_software_on_archlinux
install_fonts_on_linux
begin_install_vimplus
}
# 在linux平上台安装vimplus
function install_vimplus_on_linux()
{
distro=`get_linux_distro`
echo "Linux distro: "${distro}
if [ ${distro} == "Ubuntu" ]; then
install_vimplus_on_ubuntu
elif [ ${distro} == "Deepin" ]; then
# install_vimplus_on_ubuntu_like
not_implement
elif [ ${distro} == "LinuxMint" ]; then
# install_vimplus_on_ubuntu_like
not_implement
elif [ ${distro} == "elementaryOS" ]; then
# install_vimplus_on_ubuntu_like
not_implement
elif [ ${distro} == "Debian" ]; then
# install_vimplus_on_debian
not_implement
elif [ ${distro} == "Kali" ]; then
# install_vimplus_on_debian
not_implement
elif [ ${distro} == "CentOS" ]; then
# install_vimplus_on_centos
not_implement
elif [ ${distro} == "fedora" ]; then
# install_vimplus_on_fedora
not_implement
elif [ ${distro} == "openSUSE" ]; then
# install_vimplus_on_opensuse
not_implement
elif [ ${distro} == "ArchLinux" ]; then
install_vimplus_on_archlinux
elif [ ${distro} == "ManjaroLinux" ]; then
install_vimplus_on_archlinux
else
echo "Not support linux distro: "${distro}
fi
}
# 获取当前时间戳
function get_now_timestamp()
{
cur_sec_and_ns=`date '+%s-%N'`
echo ${cur_sec_and_ns%-*}
}
function not_implement()
{
echo "Not implement, please draft an issue in https://github.com/wyg1997/neovimplus/issues"
}
# main函数
function main()
{
begin=`get_now_timestamp`
type=$(uname)
echo "Platform type: "${type}
if [ ${type} == "Darwin" ]; then
install_vimplus_on_mac
elif [ ${type} == "Linux" ]; then
tp=$(uname -a)
if [[ $tp =~ "Android" ]]; then
echo "Android"
# install_vimplus_on_android
not_implement
else
install_vimplus_on_linux
fi
else
echo "Not support platform type: "${type}
fi
end=`get_now_timestamp`
second=`expr ${end} - ${begin}`
min=`expr ${second} / 60`
echo "It takes "${min}" minutes."
}
# 调用main函数
main