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