-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.sh
executable file
·97 lines (83 loc) · 2.06 KB
/
run.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
#!/bin/bash
python_cmd="python"
install_prereqs() {
local OS=$(uname -s | tr '[:upper:]' '[:lower:]')
local install_cmd=""
case $OS in
"darwin")
local ARCH=$(uname -m | tr '[:upper:]' '[:lower:]')
case $ARCH in
"arm64")
brew install vim cmake ctags python3 java 2>/dev/null
;;
*)
brew install vim macvim cmake ctags python3 java 2>/dev/null
;;
esac
python_cmd="python3"
;;
"linux")
hash vim && hash cmake && hash ctags || ( echo "Dependency for ${OS} is missing" && exit 1 )
hash yum && yum install -y vim cmake ctags 2>/dev/null
;;
"")
echo "OS Name came back blank, can't proceed"
exit 1
;;
*)
echo "${OS} is currently not supported by this install script"
exit 1
;;
esac
}
check_git_deps() {
DEPS=$(ls "$HOME/.vim/bundle" | head -n 1)
if [[ ! -f "$HOME/.vim/bundle/$DEPS/.git" ]]; then
echo "Dependencies don't exist; you probably forgot to run:"
printf "\n\tgit submodule update --init --recursive\n\n"
exit 1
fi
}
configure() {
install_prereqs
check_git_deps
}
install_ycm() {
CWD=$PWD
$python_cmd $HOME/.vim/bundle/YouCompleteMe/install.py --clang-completer --cs-completer --go-completer --rust-completer --ts-completer
cd $CWD
}
install_md_preview() {
CWD=$PWD
cd $HOME/.vim/bundle/markdown-preview
yarn install
cd $CWD
}
archive_old() {
[ -e "$HOME/.vimrc" -a ! -h "$HOME/.vimrc" ] && mv $HOME/.vimrc $HOME/.vimrc.old && echo "Archiving old vimrc"
}
symlink() {
if [ ! -e "$HOME/.vimrc" ] || [ "$(ls -l "$HOME/.vimrc" | awk -F"-> " '{print $2}')" != "$HOME/.vim/vimrc" ]; then
ln -f -s "$HOME/.vim/vimrc" "$HOME/.vimrc"
fi
}
update() {
git submodule foreach git checkout $(git symbolic-ref refes/remotes/origin/HEAD | cut -d '/' -f4) && git submodule foreach git pull
CWD=$PWD
cd bundle/YouCompleteMe
git submodule update --init --recursive
cd $PWD
git submodule update --init --recursive
}
install() {
configure
install_ycm
#install_md_preview
archive_old
symlink
}
if [ $# -eq 0 ]; then
install
else
"$@"
fi