]> git.sthu.org Git - vimconf.git/blob - install.sh
init: New detectspelllang conf
[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_requirements()
36 {
37 check_prog aspell
38 check_prog curl
39 check_prog git
40 check_vim +python3
41 check_py3 neovim
42 }
43
44 backup() {
45 if [ -e $1 ]; then
46 echo " Move $1"
47 mv $1 $2/
48 fi
49 }
50
51 install() {
52 BACKUPDIR=$(mktemp -d "$HOME/.vim-old-XXXXXXXX")
53 echo "Move old vim files to $BACKUPDIR"
54 backup $HOME/.viminfo $BACKUPDIR
55 backup $HOME/.vimrc $BACKUPDIR
56 backup $HOME/.gvimrc $BACKUPDIR
57 backup $HOME/.config/nvim $BACKUPDIR
58
59 echo ""
60 echo "Installing files..."
61 echo "# Empty" > $HOME/.viminfo
62 ln -s $HOME/.vim/init.vim $HOME/.vimrc
63 ln -s $HOME/.vim/gvimrc $HOME/.gvimrc
64 ln -s $HOME/.vim $HOME/.config/nvim
65
66 echo ""
67 echo "vim-startify may complain about invalid viminfo file. It will"
68 echo "disappear once you opened the first file."
69 echo ""
70 echo "Add this line to your shell configuration, e.g., ~/.profile, to"
71 echo "use vim as man pager:"
72 echo " export MANPAGER=\"view -c MANPAGER -\""
73 }
74
75
76 check_requirements
77 install