-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_nvim_centos.sh
executable file
·146 lines (121 loc) · 4.22 KB
/
install_nvim_centos.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
#!/usr/bin/env bash
{ # this ensures the entire script is downloaded #
refresh_sudo_indefinitely()
{
while true; do
/usr/bin/sudo -v && sleep 5 || { echo "sudo verification failed"; break; }
done
}
exit_on_error() {
exit_code=$1
if [ $exit_code -ne 0 ]; then
>&2 echo "-------------------------------------------------"
>&2 echo "Command failed with exit code ${exit_code}."
>&2 echo "-------------------------------------------------"
kill $(jobs -p)
exit $exit_code
fi
}
exit_on_requirment() {
exit_code=$1
if [ $exit_code -ne 0 ]; then
>&2 echo "-------------------------------------------------"
>&2 echo $2
>&2 echo "-------------------------------------------------"
kill $(jobs -p)
exit $exit_code
fi
}
# check requirements
if [ "$EUID" -eq 0 ]
then echo "Can't run as root"
exit
fi
python3 --version
exit_on_requirment $? "python3 required by this script"
# Get SUDO credentials for later use
/usr/bin/sudo -v
refresh_sudo_indefinitely &
# Install prereqs
sudo yum -y install ninja-build libtool autoconf automake cmake gcc gcc-c++ make pkgconfig unzip patch
exit_on_error $?
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.35.0/install.sh | bash
exit_on_error $?
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
nvm install node
exit_on_error $?
nvm list
curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
exit_on_error $?
sudo yum -y install yarn
npm install -g diff-so-fancy
mkdir -p ~/tools && pushd ~/tools
if [ ! -d neovim ]; then
>&2 echo "------------------------------------------------------------"
>&2 echo " BUILDING NEOVIM"
>&2 echo "------------------------------------------------------------"
git clone https://github.com/neovim/neovim
exit_on_error $?
cd neovim
git checkout stable
exit_on_error $?
make CMAKE_BUILD_TYPE=Release
exit_on_error $?
./build/bin/nvim --version | grep ^Build
sudo make install
nvim --version
exit_on_error $?
else
>&2 echo "------------------------------------------------------------"
>&2 echo " SKIPPING NEOVIM BUILD SINCE ~/tools/neovim ALREADY EXISTS."
>&2 echo "------------------------------------------------------------"
fi
popd
python3 --version
exit_on_error $?
if python -c 'import pkgutil; exit(not pkgutil.find_loader("neovim"))'; then
echo 'python2 neovim found'
else
pip2 install --user neovim
fi
if python3 -c 'import pkgutil; exit(not pkgutil.find_loader("neovim"))'; then
echo 'python3 neovim found'
else
pip3 install --user neovim
fi
exit_on_error $?
npm install -g neovim
yarn global add neovim
sudo ln -sf /usr/local/bin/nvim /usr/bin/nvim
# config
pushd ~
if [ ! -d jbyconfig ]; then
git clone https://github.com/byates/jbyconfig.git
exit_on_error $?
fi
if [ ! -d .config/nvim ]; then
mkdir -p ~/.config/nvim
ln -s ~/jbyconfig/nvim/init.vim ~/.config/nvim/init.vim
ln -s ~/jbyconfig/nvim/vim_go_init.vim ~/.config/nvim/vim_go_init.vim
ln -s ~/jbyconfig/nvim/vim_ui_init.vim ~/.config/nvim/vim_ui_init.vim
ln -s ~/jbyconfig/nvim/vim_cpp_init.vim ~/.config/nvim/vim_cpp_init.vim
ln -s ~/jbyconfig/nvim/vim_keys_init.vim ~/.config/nvim/vim_keys_init.vim
ln -s ~/jbyconfig/nvim/vim_python_init.vim ~/.config/nvim/vim_python_init.vim
ln -s ~/jbyconfig/nvim/vim_editing_init.vim ~/.config/nvim/vim_editing_init.vim
ln -s ~/jbyconfig/nvim/vim_plugins_init.vim ~/.config/nvim/vim_plugins_init.vim
ln -s ~/jbyconfig/nvim/coc-settings.json ~/.config/nvim/coc-settings.json
else
>&2 echo "------------------------------------------------------------"
>&2 echo " SKIPPING CONFIG UPDATE SINCE ~/.config/nvim ALREADY EXISTS"
>&2 echo "------------------------------------------------------------"
fi
popd
kill $(jobs -p)
>&2 echo ""
>&2 echo ""
>&2 echo "------------------------------------------------------------"
>&2 echo " RESTART SHELL BEFORE RUNNING NVIM FOR THE FIRST TIME. "
>&2 echo "------------------------------------------------------------"
} # this ensures the entire script is downloaded #