.PHONY: all
all: doc

.PHONY: doc
doc:
	vimdoc .

.PHONY: profile
profile:
	vim \
		-u test/vimrc \
		--cmd 'profile  start test/profile.out' \
		--cmd 'profile! file  ./**.vim' \
		-c    'args **/*.*' \
		-c    'qall!'

.PHONY: test
test:
	vim \
		-u test/vimrc \
		-c 'args test/test.in' \
		-c 'set commentstring=#%s shiftwidth=2' \
		-c 'UnobtrusiveFoldComment!' \
		-c 'UnobtrusiveFoldDebug' \
		-c 'write! test/test.out' \
		-c 'qall!'
	diff --color -u test/test.txt test/test.out

.PHONY: demo
demo:
	printf '%s %s\n' \
		'vimrc' '~/.vim/vimrc' \
		'yaml'  '~/projects/ansible/playbook/desktop/desktop.yml' \
	| while read name file; \
	do \
		< /dev/null asciinema rec "doc/demo-$$name.cast" \
			--overwrite \
			--title "demo-$$name" \
			--cols=80 \
			--rows=50 \
			--command "vim \
				-u test/vimrc \
				-c 'silent call Demo(\"$$file\")' \
			"; \
		svg-term \
			--from 50 \
			--in  "doc/demo-$$name.cast" \
			--out "doc/demo-$$name.svg"; \
	done