-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathinstall.sh
executable file
·171 lines (145 loc) · 4.91 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
#!/bin/bash
set -e
echo '-- Welcome to Archibate Vimrc installation script :)'
cd "$(dirname $0)"/..
test -d ./.vim
get_linux_distro() {
if grep -Eq "Ubuntu" /etc/*-release; then
echo "Ubuntu"
elif grep -Eq "Deepin" /etc/*-release; then
echo "Deepin"
elif grep -Eq "Raspbian" /etc/*-release; then
echo "Raspbian"
elif grep -Eq "uos" /etc/*-release; then
echo "UOS"
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 "Parrot" /etc/*-release; then
echo "Parrot"
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"
elif grep -Eq "Gentoo" /etc/*-release; then
echo "Gentoo"
elif grep -Eq "alpine" /etc/*-release; then
echo "Alpine"
else
echo "Unknow"
fi
}
install_coc_plugins() {
for x in coc-ccls coc-pyright coc-json coc-git; do
echo "-- Installing coc plugin '$x', please wait..."
echo -e '\n\nZZZZ\n\n' | vim --not-a-term -c "echo 'installing $x, please wait...' | CocInstall -sync $x | echo 'done' | quit"
done
mkdir -p ~/.config/coc/extensions/node_modules/coc-ccls
ln -sf node_modules/ws/lib ~/.config/coc/extensions/node_modules/coc-ccls/lib
echo '-- coc plugins installed successfully'
}
install_pacman() {
sudo pacman -S --noconfirm fzf ripgrep
sudo pacman -S --noconfirm nodejs
sudo pacman -S --noconfirm ccls
install_coc_plugins
}
install_ccls_from_source() {
cd .vim/ccls
rm -rf /tmp/ccls-build.$$
cmake -B /tmp/ccls-build.$$ -DCMAKE_BUILD_TYPE=Release
cmake --build /tmp/ccls-build.$$ --config Release --parallel 4
sudo cmake --build /tmp/ccls-build.$$ --config Release --target install
rm -rf /tmp/ccls-build.$$
cd ../..
}
install_nodejs_lts() {
if ! which node || [ `node --version | sed s/v// | cut -f1 -d.` -lt 12 ]; then
echo '-- Upgrading Node.js to 12.x'
sudo bash -c 'curl -sL install-node.vercel.app/lts | bash -s - --force --prefix /usr'
node --version
fi
}
install_apt() {
sudo apt-get install -y fzf ripgrep
sudo apt-get install -y clang libclang-dev
sudo apt-get install -y cmake make g++
sudo apt-get install -y curl
install_ccls_from_source
install_nodejs_lts
install_coc_plugins
}
install_fzf_from_source() {
cd .vim
git clone https://github.com/junegunn/fzf.git --depth=1
cd fzf
make
sudo make install
cd ../..
}
install_ripgrep_from_source() {
cd .vim
git clone https://github.com/BurntSushi/ripgrep.git --depth=1
cd ripgrep
cargo build --release
./target/release/rg --version
sudo cp ./target/release/rg /usr/local/bin
cd ../..
}
install_any() {
install_fzf_from_source
install_ripgrep_from_source
install_ccls_from_source
install_nodejs_lts
install_coc_plugins
}
distro=`get_linux_distro`
echo "-- Linux distro detected: $distro"
if [ $distro == "Ubuntu" ]; then
install_apt
elif [ $distro == "Debian" ]; then
install_apt
elif [ $distro == "ArchLinux" ]; then
install_archlinux
elif [ $distro == "ManjaroLinux" ]; then
install_pacman
else
# TODO: add more Linux distros here..
# TODO: how to detect MacOS and Windows?
echo "-- Unsupported distro: $distro"
echo "-- The script will try to install these packages from source: fzf ripgrep ccls"
echo "-- Note that fzf requires Go, ripgrep requires Rust, ccls requires Clang and LLVM to build, make sure you have them.."
echo "-- If you know how to install them, feel free to contribute to this GitHub repository: github.com/archibate/vimrc"
echo "-- Also, Node.js 12.x or above is required. Try the following patch script if you meet issues about coc.nvim:"
cat <<EOF
mkdir -p ~/.config/coc/extensions/node_modules/coc-ccls
ln -sf node_modules/ws/lib ~/.config/coc/extensions/node_modules/coc-ccls/lib
EOF
echo -n "-- Continue installing from source (y/N)? "; read -n1 x; echo
if [ "x$x" != "xy" ]; then exit 1; fi
install_any
fi
if [ "x$PWD" != "x$HOME" ]; then
if [ -f ~/.vimrc ]; then
echo "-- backup existing .vimrc to ~/.vimrc.backup.$$"
mv ~/.vimrc ~/.vimrc.backup.$$
fi
if [ -d ~/.vim ]; then
echo "-- backup existing .vim to ~/.vim.backup.$$"
mv ~/.vim ~/.vim.backup.$$
fi
echo "-- installing .vimrc and .vim"
cp -r .vimrc .vim ~/
echo "-- installation complete, thank you for choosing archibate/vimrc"
fi