refactor: finish moving ssh-* scripts to own installers
[webi-installers/.git] / vim-spell / install.sh
1 #!/bin/bash
2
3 function __init_vim_spell() {
4     set -e
5     set -u
6
7     mkdir -p "$HOME/.vim/plugins"
8     rm -rf "$HOME/.vim/plugins/spell.vim"
9
10     echo ""
11
12     if [ ! -e "$HOME/.vimrc" ]; then
13         touch "$HOME/.vimrc"
14     fi
15
16     if ! [ -f "$HOME/.vim/plugins/spell.vim" ]; then
17         mkdir -p ~/.vim/plugins
18         WEBI_HOST=${WEBI_HOST:-"https://webinstall.dev"}
19         curl -fsS -o ~/.vim/plugins/spell.vim "$WEBI_HOST/packages/vim-spell/spell.vim"
20     fi
21
22     if ! grep 'source.*plugins.spell.vim' -r ~/.vimrc > /dev/null 2> /dev/null; then
23         set +e
24         mkdir -p ~/.vim/plugins
25         printf '\n" Spell Check: reasonable defaults from webinstall.dev/vim-spell\n' >> ~/.vimrc
26         printf 'source ~/.vim/plugins/spell.vim\n' >> ~/.vimrc
27         set -e
28         echo "added ~/.vim/plugins/spell.vim"
29         echo "updated ~/.vimrc with 'source ~/.vim/plugins/spell.vim'"
30         echo ""
31     fi
32
33     echo "vim-spell enabled with reasonable defaults"
34 }
35
36 __init_vim_spell