darkcloud-nvimconfig/update

67 lines
2.8 KiB
Text
Raw Normal View History

#!/usr/bin/env bash
# work from the base directory of the repository
cd "${0%/*}"
# create the user vimrc file in the directory if it doesn't already exist
[[ ! -d vim ]] && install -d vim
if [ ! -e vim/vimrc.user ]; then
echo "Creating user configuration file 'vim/vimrc.user'..."
if [ -w vim ]; then
echo -e '"Disable Linebreaks: (*1:force disabled globally | 0: disabled by default)\n"let g:disablelinebreaks=0\n' >> vim/vimrc.user
echo -e '"Autostart Filer: (*1:filer loads in new empty buffers | 0: filer must be triggered)\n"let g:autostartfiler=0\n' >> vim/vimrc.user
echo -e '"Syntax Autostart: (1:start toggled on | *0: start toggled off)\n"let g:autostartchecker=1\n' >> vim/vimrc.user
echo -e '"Tagbar Autostart: (1:start open | *0:start closed)\n"let g:autostarttagbar=1\n' >> vim/vimrc.user
echo -e '"Powerline Fonts: (1:enabled | *0:disabled)\n"let g:powerlinefonts=1 "(set powerline font for gvim and terminal when enabled)\n' >> vim/vimrc.user
echo -e '"GVim Font Selection: (Escaping spaces and use powerline if appropriate)\nset guifont=Monospace\ 12' >> vim/vimrc.user
fi
echo
fi
echo "Updating darkcloud-vimconfig..."
git pull origin
git submodule sync
echo -e "\nUpdating plugin submodules..."
git submodule update --init --recursive
# delete submodules in vim/bundle that were removed up stream
echo -e "\nConfiguring plugin submodules..."
[[ -f .gitmodules ]] && for each in vim/bundle/*; do
if [ -d "$each" ]; then
if [ -f "${each}/.git" ]; then
FILE=$(echo $each | grep -o -e "[^\/]*$")
[[ `cat .gitmodules | grep "path = " | grep -o -e "[^\/]*$" | grep -c -e "${FILE}$"` = 0 ]] && (rm -rf "${each}" && echo "Deleted: ${each}" || (echo -e "\033[01;31mWARNING\033[00m: '${each}' was removed upstream but couldn't be deleted here.\n\nPlease delete ${each} manually."; exit 1))
fi
fi
done
echo
# update git-based plugins in vim/bundle.user if any exist
if [ ! $(find vim/bundle.user | grep ".git/config" | wc -l) = 0 ]; then
echo "Updating custom plugins in 'vim/bundle.user':"
pushd vim/bundle.user > /dev/null 2>&1
for each in *; do
if [ -d "$each" ]; then
pushd "$each" > /dev/null 2>&1
if [ -d .git ]; then
echo -e "\nUpdating git repo: ${each}..."
git pull
elif [ -f .git ]; then
echo -e "\nUpdating git submodule: ${each}..."
git pull origin master
fi
popd > /dev/null 2>&1
fi
done
popd > /dev/null 2>&1
echo
fi
echo "Generating updated helpdocs for installed plugins..."
[[ `type -P vim` ]] && vim -c "Helptags|qa!" &>/dev/null 2>&1
echo
echo "Update Complete!"
exit 0