chore(style): add shebang, set bash strict mode, create function
[webi-installers/.git] / vim-ale / install.sh
1 #!/bin/bash
2
3 function __init_vim_ale() {
4     set -e
5     set -u
6
7     mkdir -p "$HOME/.vim/pack/plugins/start"
8     rm -rf "$HOME/.vim/pack/plugins/start/ale"
9     git clone --depth=1 https://github.com/dense-analysis/ale.git "$HOME/.vim/pack/plugins/start/ale"
10
11     if [ ! -f "$HOME/.vimrc" ]; then
12         touch "$HOME/.vimrc"
13     fi
14
15     mkdir -p ~/.vim/plugins
16     if ! [ -f "$HOME/.vim/plugins/ale.vim" ]; then
17         WEBI_HOST=${WEBI_HOST:-"https://webinstall.dev"}
18         curl -fsSL -o ~/.vim/plugins/ale.vim "$WEBI_HOST/packages/vim-ale/ale.vim"
19     fi
20
21     if ! grep 'source.*plugins.ale.vim' -r ~/.vimrc > /dev/null 2> /dev/null; then
22         set +e
23         mkdir -p ~/.vim/plugins
24         printf '\n" ALE: reasonable defaults from webinstall.dev/vim-ale\n' >> ~/.vimrc
25         printf 'source ~/.vim/plugins/ale.vim\n' >> ~/.vimrc
26         set -e
27         echo ""
28         echo "add ~/.vim/plugins/ale.vim"
29         echo "updated ~/.vimrc with 'source ~/.vim/plugins/ale.vim'"
30     fi
31
32     echo ""
33     echo "vim-ale enabled with reasonable defaults"
34
35 }
36
37 __init_vim_ale