#!/bin/zsh
source "$HOME/.config/wryn/env.zsh"
#####################################################################

UPDATE() {
	local VIM_PATH="$HOME/.local/share/source-packages/vim"

	VIM_INSTALL --only-pull || return 1

	cd "$VIM_PATH"
	__STATUS 'configuring vim'
	./configure \
			--with-features=huge \
			--enable-cscope \
			--enable-gtk2-check \
			--enable-gtk3-check \
			--with-x \
			--enable-gui=auto \
			--enable-luainterp=yes \
			--enable-perlinterp=yes \
			--enable-python3interp=yes \
			--enable-rubyinterp=yes \
			--enable-terminal \
		&& __SUCCESS 'finished configuring vim' \
		|| __FAIL 3 'failed to configure vim (see above)' \
		;

	VIM_INSTALL $@ --only-build || __FAIL 2 'vim build failed (try with --clean for make clean)'

	VUNDLE_INSTALL || __FAIL 3 'vundle plugin install failed'
}

VIM_INSTALL() {
	scwrypts -n packages/install -- \
		--target-url 'https://github.com/vim/vim.git' \
		--local-name 'vim' \
		--update \
		$@
}

VUNDLE_INSTALL() {
	"$DOTWRYN/bin/scwrypts" --env local --no-log \
		zsh/vim/vundle/install $@
}

#####################################################################
UPDATE $@