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