-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
185 lines (152 loc) · 5.17 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
#!/bin/bash
set -e
if [ "$(uname -s)" == "Darwin" ]; then
echo "You are using MacOS."
# Your macOS script here
OS_TYPE="MAC"
INSTALLER=brew
INSTALLER_OPTION="-q"
SED="gsed"
export HOMEBREW_NO_AUTO_UPDATE=1
else
if grep -q 'Ubuntu' /etc/os-release; then
echo "You are using Ubuntu."
OS_TYPE="UBUNTU"
INSTALLER=apt-get
INSTALLER_OPTION="-y -q"
SED="sed"
${INSTALLER} update
elif grep -q 'Debian' /etc/os-release; then
echo "You are using Debian."
OS_TYPE="UBUNTU"
INSTALLER=apt-get
INSTALLER_OPTION="-y -q"
SED="sed"
${INSTALLER} update
else
echo "You are using Linux but not Ubuntu."
exit 1
fi
fi
echo ""
if [[ ${OS_TYPE} == "UBUNTU" ]]; then
vim --version | head -1
echo "Upgrade Vim ..."
echo ""
${INSTALLER} install ${INSTALLER_OPTION} software-properties-common
add-apt-repository -y ppa:jonathonf/vim && \
${INSTALLER} update ${INSTALLER_OPTION} && \
${INSTALLER} install ${INSTALLER_OPTION} vim
echo ""
vim --version | head -1
echo ""
elif [[ ${OS_TYPE} == "MAC" ]]; then
echo "Upgrade Vim ..."
${INSTALLER} reinstall ${INSTALLER_OPTION} vim
echo ""
echo "Install gsed ..."
${INSTALLER} install ${INSTALLER_OPTION} ${SED}
echo ""
fi
if [[ $(which pip3) ]]; then
PIP=$(which pip3)
echo "Use pip ${PIP}"
elif [[ $(which pip) ]]; then
PIP=$(which pip)
echo "Use pip ${PIP}"
else
echo "There is no pip or pip3. Please Install python3-pip."
exit 1
fi
echo "Install Vundle.vim ..."
VIM_DIR=${HOME}/.vim
if [[ -e ${VIM_DIR} ]]; then
echo "${VIM_DIR} is already exists. Back-up ${VIM_DIR} file into ${HOME}/.vim_bak"
rm -rf ${HOME}/.vim_bak
mv ${VIM_DIR} ${HOME}/.vim_bak
fi
mkdir -p ${VIM_DIR}
mkdir -p ${VIM_DIR}/bundle
rm -rf ${VIM_DIR}/bundle/Vundle.vim
git clone https://github.com/VundleVim/Vundle.vim.git ${VIM_DIR}/bundle/Vundle.vim
echo ""
echo "Install colors ..."
mkdir -p ${VIM_DIR}/colors
wget https://raw.githubusercontent.com/joshdick/onedark.vim/main/colors/onedark.vim -O ${VIM_DIR}/colors/onedark.vim
mkdir -p ${VIM_DIR}/autoload
wget https://raw.githubusercontent.com/joshdick/onedark.vim/main/autoload/onedark.vim -O ${VIM_DIR}/autoload/onedark.vim
echo ""
echo "Install Node.js ..."
function check_node_version() {
target_major=22
# Get current Node.js version, removing the leading 'v'
current_version=$(node -v | sed 's/v//')
# Break current version into components
current_major=$(echo $current_version | cut -d. -f1)
# Compare major version component only
if [ $current_major -lt $target_major ]; then
return 1
else
return 0
fi
}
NODE_MAJOR_VERSION="22"
if [[ ${OS_TYPE} == "UBUNTU" ]]; then
if NODE_PATH=$(which node); then
if [[ check_node_version ]]; then # if current node version is less then 17.x.x
# remove node
rm -f /etc/apt/sources.list.d/nodesource.list && \
apt --fix-broken install && \
apt update && \
apt remove -y nodejs nodejs-doc && \
apt autoremove -y
fi
fi
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
# download and install Node.js (you may need to restart the terminal)
nvm install ${NODE_MAJOR_VERSION}
elif [[ ${OS_TYPE} == "MAC" ]]; then
${INSTALLER} install ${INSTALLER_OPTION} node@${NODE_MAJOR_VERSION}
fi
echo ""
echo "Install Language Server Dependencies ..."
${PIP} install -q autopep8 flake8 # Python Language Server dependency
${INSTALLER} install ${INSTALLER_OPTION} ccls # C/C++ langauge server dependency
npm install -g bash-language-server # bash langauge server dependency
npm install -g eslint eslint-plugin-vue -D # vue langauge server dependency
npm install -g dockerfile-language-server-nodejs # dockerfile langauge server dependency
echo ""
echo "Install CoC.nvim ..."
git clone https://github.com/neoclide/coc.nvim.git -b release ~/.vim/bundle/coc.nvim
echo ""
echo "Install ctags ..."
if [[ ${OS_TYPE} == "UBUNTU" ]]; then
${INSTALLER} install ${INSTALLER_OPTION} exuberant-ctags
elif [[ ${OS_TYPE} == "MAC" ]]; then
${INSTALLER} install ${INSTALLER_OPTION} ctags
fi
echo ""
echo "Apply .vimrc ..."
if [[ -e ${HOME}/.vimrc ]]; then
echo "${HOME}/.vimrc is already exists. Back-up ${HOME}/.vimrc file into ${HOME}/.vimrc_bak"
mv ${HOME}/.vimrc ${HOME}/.vimrc_bak
fi
cp ${PWD}/vimrc ${HOME}/.vimrc
vim -c 'PluginInstall' -c 'qa!'
echo ""
echo "Install CoC Language Servers ..."
echo ':CocInstall -sync coc-snippets coc-pyright coc-json coc-java coc-tsserver coc-html coc-css coc-vetur coc-cmake|q' > coc_install.vim
vim -s coc_install.vim
rm coc_install.vim
echo "Apply CoC Settings ..."
cp ${PWD}/coc-settings.json ${VIM_DIR}/coc-settings.json
PYTHONPATH=$(which python3)
echo "PYTHON3 BINARY: ${PYTHONPATH}"
ESCAPED="${PYTHONPATH//\//\\/}"
${SED} -i "s/\"python.pythonPath\": \"python3\"/\"python.pythonPath\": \"${ESCAPED}\"/" ${VIM_DIR}/coc-settings.json
echo ""
echo "Apply CoC Python Snippets ..."
mkdir -p ${HOME}/.config/coc/ultisnips
cp ${PWD}/snippets/* ${HOME}/.config/coc/ultisnips/
echo ""
echo "awesome-vim-setting is finished!"