From 3351a95a0a3a3c95dbcd73eb81510eac161cf2e3 Mon Sep 17 00:00:00 2001 From: Joe Groocock Date: Mon, 18 Dec 2017 16:53:43 +0000 Subject: [PATCH] Modernise and improve vim-setup script --- .profile | 3 ++- scripts/vim-setup | 23 +++++++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/.profile b/.profile index 526626e..ce8e579 100644 --- a/.profile +++ b/.profile @@ -9,7 +9,8 @@ export PATH="${PATH}:$DOTFILES/scripts" export XDG_CURRENT_DESKTOP="GNOME" # Fixes xdg-open # Allow Vim to load from ~/.config/vim -export MYVIMRC="$CONFIG_DIR/vim/vimrc" +export VIMDIR="$CONFIG_DIR/vim" +export MYVIMRC="$VIMDIR/vimrc" export VIMINIT=":so $MYVIMRC" export EDITOR="vim" diff --git a/scripts/vim-setup b/scripts/vim-setup index 2810569..3719dce 100755 --- a/scripts/vim-setup +++ b/scripts/vim-setup @@ -1,18 +1,29 @@ -YCM=~/.vim/bundle/YouCompleteMe +#!/bin/sh +set -e -sudo pacman -Sy python cmake clang --needed --noconfirm +############################ +## Check for dependencies ## +############################ +error() { >&2 printf "Error: %s" "$1"; exit 1; } + +which cmake >/dev/null 2>&1 || error 'cmake is not installed' +which clang >/dev/null 2>&1 || error 'clang is not installed' +which python >/dev/null 2>&1 || error 'python is not installed' + +[ -z "$VIMDIR" ] && error '$VIMDIR is not set' ####################### ## Initialise Vundle ## ####################### -mkdir -p ~/.vim/{bundle,swapfiles} -git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim +mkdir -p "$VIMDIR/bundle" "$VIMDIR/swapfiles" +if [ ! -d "$VIMDIR/bundle/Vundle.vim" ]; then + git clone https://github.com/VundleVim/Vundle.vim.git "$VIMDIR/bundle/Vundle.vim" +fi vim +PluginUpdate +qall - ######################### ## Setup YouCompleteMe ## ######################### -cd "$YCM" +cd "$VIMDIR/bundle/YouCompleteMe" git submodule update --init --recursive ./install.py --system-libclang --clang-completer