I'm trying to combine fzf-bibtex with UltiSnips so that I can search my bibliography file and insert a BibTeX key automatically. I use the following function from fzf-bibtex
(which calls the binaries bibtex-cite
and bibtex-ls
on my system, they just format and output the BibTeX key):
function! s:bibtex_cite_sink_insert(lines)
let r=system("bibtex-cite ", a:lines)
execute ':normal! i' . r
call feedkeys('a', 'n')
endfunction
inoremap <silent> @@ <c-g>u<c-o>:call fzf#run({
\ 'source': 'bibtex-ls',
\ 'sink*': function('<sid>bibtex_cite_sink_insert'),
\ 'up': '40%',
\ 'options': '--ansi --layout=reverse-list --multi --prompt "Cite> "'})<CR>
And in my markdown.snippets
file I have the following snippet:
snippet q "Quote" i
[$1, $2] $0
endsnippet
If i now press @@
in insert mode when at position $1
after the snipped expanded, it works fine and the fzf
prompt with my BibTeX entries is opened.
However, I wanted to automatically call this prompt when the snippet expanded. I thought that could maybe be done with telling vim to just type in @@
when at snippet position $1
, so I said:
snippet q "Quote" i
[`!v feedkeys('@@')`, $2] $0
endsnippet
The fzf
prompt gets indeed invoked, but it stays in an infinite loop after it entered the selected key, opening the prompt again and again. I can't even quit it with Esc
or Ctrl-c
.
What did I do wrong? Thanks for helping.