function! lbdb_omni#complete(findstart, base)
	if a:findstart
		let l:comma_pos = searchpos('[:,]\zs', 'bncW', line('.'))
		if l:comma_pos[0] == line('.')
			return l:comma_pos[1]
		else
			return 0
		endif
	else
		let l:out = split(system('lbdbq '.shellescape(a:base)), '\n')
		if ! len(l:out) | return | endif
		echo l:out[0].'  '.a:base
		let l:out = l:out[1:]
		let l:matches = []
		if ! len(l:out) | return | endif
		for [l:addr, l:name, l:added] in map(l:out, 'split(v:val, "\t")')
			let l:matches+=[{
				\ 'word': '"'.l:name.'" <'.l:addr.'>',
				\ 'menu': l:added }]
		endfor
		return [a:base]+l:matches
	endif
endfunction