-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·211 lines (160 loc) · 4.67 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
#!/bin/bash -x
# # Make sure the script is run as root
# if [ "$EUID" -ne 0 ]; then
# echo "Please run as root:"
# echo "sudo $0"
# exit 1
# fi
error_exit() {
# Error message
echo "Fatal: !! retunred exit status $?, exiting..."
exit 1
}
install_nvim_from_source() {
INSTALL_DIR=/opt/neovim
# Grab the most recent stable release of Neovim
git submodule update --init || error_exit
cd neovim && git checkout stable
# Install Neovim!
make --silent CMAKE_BUILD_TYPE=Release CMAKE_EXTRA_FLAGS="-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR"
sudo make --silent install
if [[ $? -eq 0 ]]; then
# Make a symlink to the executable
sudo ln -s $INSTALL_DIR/bin/nvim /usr/local/bin/nvim
# Done!
return 0
else
# Error message
echo "Fatal: Make returned a non-zero exit status, exiting..."
exit 1
fi
}
install_neovim() {
# Try to install the easy way first
echo "Installing Neovim via AppImage..."
# URL to the latest Neovim AppImage
NEOVIM_INSTALL_URL="https://github.com/neovim/neovim/releases/latest/download/nvim.appimage"
# Download the appimage and make it executable
curl -LO $NEOVIM_INSTALL_URL && chmod u+x nvim.appimage
# Get the full path to the appimage
NVIM_APPIMAGE=$(readlink -f ./nvim.appimage)
# Check if the appimage works
./nvim.appimage --version
if [[ $? -eq 0 ]]; then
# If it works, then move it to /usr/local/bin
sudo mv $NVIM_APPIMAGE /usr/local/bin/nvim
# Done!
return 0
else
# If it doesn't work, then delete it
rm $NVIM_APPIMAGE
# Prompt
echo "AppImage is incompatible, installing Neovim from source..."
# Install Neovim from source
install_nvim_from_source
return $? # Return the exit status of the function
fi
}
#################### Script Start ####################
# Parse input flags
for i in "$@"; do
case $i in
-h | --help)
echo "Usage: $0 [options]"
echo ""
echo "Options:"
echo "-h, --help Show this help message"
echo ""
exit 0
;;
esac
done
WORKING_DIR=$(pwd)
CONFIG_DIR=~/.config/nvim
# If we're not in the config directory, throw an error
if [[ ! "$WORKING_DIR" == "$CONFIG_DIR" ]]; then
cd $CONFIG_DIR || error_exit
fi
# Install tzdata and automatically configure it if necessary
if [[ ! -f /etc/timezone ]]; then
DEBIAN_FRONTEND=noninteractive TZ="Etc/UTC" apt-get -y install tzdata
fi
# Necessary packages for Neovim and plugins
declare -a PACKAGES=(
wget
curl
gcc
ninja-build
gettext
cmake
unzip
golang
cargo
ruby
ruby-dev
gem
npm
default-jdk
default-jre
luarocks
python3
python3-pip
php
composer
perl
ripgrep
fd-find
xclip
)
# Prompt
echo "Installing the following packages: ${PACKAGES[@]}"
# Install packages
sudo apt-get update >/dev/null
sudo apt-get install -y ${PACKAGES[@]} && sudo apt-get autoremove -y
# Check if Neovim is already installed
if [[ ! $(which nvim) ]]; then
# Install Neovim
install_neovim
if [[ $? -ne 0 ]]; then
echo "Fatal: Neovim was not found and could not be installed, exiting..."
exit $?
else
echo "Neovim installed successfully!"
echo "$(nvim --version)"
fi
fi
# Get python3 version to install the correct python venv package
PYTHON3_VENV=$(python3 --version | sed -E 's/Python (.\...)\.../python\1-venv/;t')
# Install python3.*-venv
echo "Installing $PYTHON3_VENV..." && sudo apt-get install -y $PYTHON3_VENV
# Create a symlink for python3 (or don't if it already exists)
if [[ ! -f /usr/local/bin/python3 ]]; then
sudo ln -s $(which python3) /usr/local/bin/python3
fi
# Install pynvim
python3 -m pip install -q -U pynvim jill
# Install neovim for ruby
gem install -q neovim && gem environment -q
# Install neovim for npm
npm install -q -g n
n -q lts latest && hash -r
npm install -q -g neovim tree-sitter-cli n
# Install cpanm and neovim for perl
yes | cpan -i CPAN::DistnameInfo -i App::cpanminus && cpan -f -i Neovim::Ext
# Run Julia install script
printf 'y\n' | jill install
# Run Neovim in headless mode to install plugins
echo "Installing Neovim plugins..."
nvim --headless -c 'autocmd User PackerComplete quitall'
nvim --headless -c 'PackerSync'
echo ''
# Check if the installation was successful
if [[ $? -eq 0 ]]; then
echo "Neovim plugins installed successfully!"
else
echo "Fatal: Neovim plugins were not installed successfully, exiting..."
exit 1
fi
# TODO: Current issues with the following:
# - clipboard
# - clangd & lemminx report "Platform is unsupported"