Omni-completion results from vimtex for references
I'd like to have omni-completion for references in a latex document. Vimtex provides results via an omnifunc (https://github.com/lervag/vimtex/blob/master/doc/vimtex.txt#L1487). I have added following pattern to my vimrc based on https://github.com/lervag/vimtex/issues/453#issuecomment-228575751:
let g:completor_tex_omni_trigger =
\ '\\(?:'
\ . '\w*cite\w*(?:\s*\[[^]]*\]){0,2}\s*{[^}]*'
\ . '|\w*ref(?:\s*\{[^}]*|range\s*\{[^,}]*(?:}{)?)'
\ . '|hyperref\s*\[[^]]*'
\ . '|includegraphics\*?(?:\s*\[[^]]*\]){0,2}\s*\{[^}]*'
\ . '|(?:include(?:only)?|input)\s*\{[^}]*'
\ .')'
First of all, this works.
\documentclass{article}
% This is the sample bib file
\begin{filecontents}{demo.bib}
@book{Saussure1995,
Author = {Ferdinand de Saussure},
Origyear = {1916},
Publisher = {Payot},
Title = {Cours de Linguistique G{\'e}n{\'e}rale},
Year = {1995}}
\end{filecontents}
\usepackage{natbib,bibentry}
\bibliographystyle{apalike}
\begin{document}
\bibliography{demo}
This is a complete citation in the middle of the text:
\bibentry{Saussure1995}
\cite{
\end{document}
You have to compile this file once to generate the file demo.bib so that omni-completion can work (relies on the file specified in \bibliography{demo.bib}.
The issue:
After entering \cite{ the waiting time for the reference is a little bit too long. I suspect this is due to a slow vimtex-omnifunc. But I would have hoped, that there would be a caching to speed things up. However, things do not change when I want to enter a second citation. Does completor caches omni-completion results for the next invocation?
BTW, I do not like that you fix cot=menuone setting. I would prefer it if you would leave this to the user.
now, you can set
let g:completor_tex_omni_trigger = g:vimtex#re#deoplete
@hanqing0521 Thanks for pointing out that vimtex provides a python regex for this.
However, this does not change the issue that completor does no caching and the omnifunc is still slow.