init: Use setlocal instead of set
[vimconf.git] / install.sh
1 #!/bin/sh
2
3 set -e
4
5 check_vim()
6 {
7 if /usr/bin/vim --version | grep -q "$1"; then
8 echo "vim has support for $1."
9 else
10 echo "vim has no support for $1. Aborting."
11 exit
12 fi
13 }
14
15 check_py3()
16 {
17 if python3 -c "import $1" 2>/dev/null; then
18 echo "Python3 module '$1' exists."
19 else
20 echo "Python3 module '$1' missing. Aborting."
21 exit
22 fi
23 }
24
25 check_prog()
26 {
27 if which "$1" > /dev/null; then
28 echo "$1 found."
29 else
30 echo "$1 not found. Aborting."
31 exit
32 fi
33 }
34
35 check_font()
36 {
37 if fc-list | grep -q "$1"; then
38 echo "Font $1 found."
39 else
40 echo "Font $1 not found. Either install it or clear g:enable_plugin_devicons."
41 exit
42 fi
43 }
44
45 check_requirements()
46 {
47 check_prog aspell
48 check_prog curl
49 check_prog git
50 check_vim +python3
51 check_py3 neovim
52 check_font "Hack NF"
53 }
54
55 backup() {
56 if [ -e $1 ]; then
57 echo " Move $1"
58 mv $1 $2/
59 fi
60 }
61
62 install() {
63 BACKUPDIR=$(mktemp -d "$HOME/.vim-old-XXXXXXXX")
64 echo "Move old vim files to $BACKUPDIR"
65 backup $HOME/.viminfo $BACKUPDIR
66 backup $HOME/.vimrc $BACKUPDIR
67 backup $HOME/.gvimrc $BACKUPDIR
68 backup $HOME/.config/nvim $BACKUPDIR
69
70 echo ""
71 echo "Installing files..."
72 echo "# Empty" > $HOME/.viminfo
73 ln -s $HOME/.vim/init.vim $HOME/.vimrc
74 ln -s $HOME/.vim/gvimrc $HOME/.gvimrc
75 ln -s $HOME/.vim $HOME/.config/nvim
76
77 echo ""
78 echo "vim-startify may complain about invalid viminfo file. It will"
79 echo "disappear once you opened the first file."
80 echo ""
81 echo "Add this line to your shell configuration, e.g., ~/.profile, to"
82 echo "use vim as man pager:"
83 echo " export MANPAGER=\"view -c MANPAGER -\""
84 }
85
86
87 check_requirements
88 install