-
Notifications
You must be signed in to change notification settings - Fork 1
/
make_neovim
57 lines (49 loc) · 1.13 KB
/
make_neovim
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
#!/bin/bash
#
# Downloads the sources of neovim and builds them.
# Create target dir if it does not exist
mkdir -p target
cd "target"
nvim_dir="`pwd`/neovim"
color_green="\E[32m"
color_red="\E[31m"
color_reset="\E[0m"
# parameters:
# $1 - the message to print
function print_msg {
printf "$color_green>>> $1$color_reset\n"
}
# parameters:
# $1 - the message to print
function print_err {
printf "$color_red>>> $1$color_reset\n"
}
function build_nvim {
print_msg "Building neovim."
make
build_ret=$?
# Check the return value of the build
if [[ $build_ret -eq 0 ]]; then
print_msg "Building neovim succeeded."
else
print_err "Building neovim failed."
fi
}
# Check if neovim directory exists
if [ -d "$nvim_dir" ]; then
print_msg "Updating neovim repo."
cd "$nvim_dir"
git fetch origin
merge_res=`git merge origin/master | head -n 1`
# Check if a new head is available
if [ "$merge_res" = "Already up-to-date." ]; then
print_msg "No update needed."
else
build_nvim
fi
else
print_msg "Cloning neovim repo."
git clone -b master git://github.com/neovim/neovim "$nvim_dir"
cd "$nvim_dir"
build_nvim
fi