# snippet completion function
global !p
def complete(t, opts):
	if t:
			opts = [m[len(t):] for m in opts if m.startswith(t)]
	if len(opts) == 1:
			return opts[0]
	elif len(opts) == 0:
			return "-error"
	return '(' + '|'.join(opts) + ')'
endglobal

# shared fragment style completion list
global !p
def fragments():
	return ['grow', 'shrink', 'fade-in', 'fade-out', 'current-visible',
			'highlight-current-blue', 'highlight-red', 'highlight-green',
			'highlight-blue']
endglobal

# reveal.js html snippets
snippet frag "reveal.js fragment class" i
fragment $1`!p snip.rv=complete(t[1], fragments())`
endsnippet

snippet bg "reveal.js data-background"
data-background="$1"$0
endsnippet

snippet trans "reveal.js data-transition"
data-transition="$1`!p snip.rv=complete(t[1], ['slide', 'none', 'fade',
											   'convex', 'concave', 'zoom'])`"
endsnippet

snippet index "reveal.js data-fragment-index"
data-fragment-index="$1"$0
endsnippet

snippet notes "reveal.js speaker notes"
<aside class="notes">
	$0
</aside>
endsnippet

# reveal.js markdown section snippets
snippet mdsec "Reveal.js markdown section"
<section data-markdown>
	<script type="text/template">
$0
	</script>
</section>
endsnippet

snippet mdelem "reveal.js markdown element"
<!-- .element: class="$1"$2 -->$0
endsnippet