-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
115 lines (95 loc) · 2.44 KB
/
setup.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
#!/bin/bash
set -e
while getopts "pno" opt; do
case "$opt" in
p)
SKIP_PY=1
;;
o)
OVERRIDE_PY=1
;;
n)
SKIP_NODE=1
;;
esac
done
cd ~/.nvim_settings
echo "Installing plug"
curl -fLo ~/.nvim_settings/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
mkdir -p ~/.config/nvim/
if [ -n "$SKIP_PY" ]; then
echo "Skipping Python setup"
else
echo "Setting up Python environments"
# Just some required python stuff
pyenv install -s 2.7.17
pyenv install -s 3.9.5
if [ -n "$OVERRIDE_PY" ]; then
if [[ $(pyenv virtualenvs) =~ "nvim_settings_py2" ]]; then
pyenv virtualenv-delete -f nvim_settings_py2
fi
if [[ $(pyenv virtualenvs) =~ "nvim_settings_py3" ]]; then
pyenv virtualenv-delete -f nvim_settings_py3
fi
fi
{
pyenv virtualenv 2.7.17 nvim_settings_py2
} || {
echo "If it already exists, setting -o will override the creation or -p will skip all python setup (may cause problems if it hasn't already been configured)"
exit 1
}
{
pyenv virtualenv 3.9.5 nvim_settings_py3
} || {
echo "If it already exists, setting -o will override the creation or -p will skip all python setup (may cause problems if it hasn't already been configured)"
exit 1
}
fi
# gross workaround to get virtualenv working
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
pyenv activate nvim_settings_py2
if [ -z "$SKIP_PY" ]; then
pip install neovim
pip install pynvim
fi
PYTHON_2_PATH=$(pyenv which python)
pyenv activate nvim_settings_py3
if [ -z "$SKIP_PY" ]; then
pip install neovim
pip install pynvim
fi
PYTHON_3_PATH=$(pyenv which python)
if [ -n "$SKIP_NODE" ]; then
echo "Skipping Node setup"
else
echo "Setting up Node"
# If yarn exists, assume we want to use it.
# otherwise use npm
{
yarn global add neovim
} || {
ERR=$?
if [ $ERR -eq 127 ]; then
npm install -g neovim
else
exit $ERR
fi
}
fi
echo "Generating Vim Scripts"
cat > ./vimscripts/generated.vim <<EOF
" Autogenerated file from setup.sh
let g:python_host_prog = '$PYTHON_2_PATH'
let g:python3_host_prog = '$PYTHON_3_PATH'
EOF
touch ~/.config/nvim/my_config.vim
touch ~/.config/nvim/my_installs.vim
cat > ~/.config/nvim/init.vim <<EOF
let \$CUSTOM_INSTALLS_FILE = "~/.config/nvim/my_installs.vim"
set runtimepath+=~/.nvim_settings
source ~/.nvim_settings/init.vim
source ~/.config/nvim/my_config.vim
EOF
echo Done