-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_vim.sh
executable file
·43 lines (33 loc) · 1.01 KB
/
setup_vim.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
#!/usr/bin/env bash
set -eo pipefail
repo=$1
force=$2
if [[ -z ${repo} || -z ${force} ]]; then
echo 1>&2 "Incorrect arguments given to setup_vim.sh; repo: $repo force: $force"
exit 1
fi
echo 1>&2 "**"
echo 1>&2 "** Setup vim"
echo 1>&2 "**"
if [[ -n $(which vim) ]]; then
mkdir -p ~/.vim/backup
# plug
if [[ ! -f ~/.vim/autoload/plug.vim ]]; then
curl -#fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
vim +PlugInstall +qall
elif [[ ${force} == "1" ]]; then
vim +PlugUpdate +qall
fi
# spell check dictionary
spell_file=${HOME}/.vim/spell/en.utf-8.add
mkdir -p $(dirname ${spell_file})
if [[ ! -f ${spell_file} || ${force} == "1" ]]; then
vim "+set spell" +spelldump +2,2d "+sav! /tmp/spelldump.txt" +qall
sed -i -e $'1s;^;/encoding=utf-8\\n;' /tmp/spelldump.txt
cat /tmp/spelldump.txt | sed "s/'/’/g" >$spell_file
vim "+mkspell! ${spell_file}" +qall
rm /tmp/spelldump.txt
fi
else
echo 1>&2 "No vim."
fi