Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Omni-completion results from vimtex for references #41

Open
kiryph opened this issue Oct 28, 2016 · 2 comments
Open

Omni-completion results from vimtex for references #41

kiryph opened this issue Oct 28, 2016 · 2 comments

Comments

@kiryph
Copy link

kiryph commented Oct 28, 2016

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 lervag/vimtex#453 (comment):

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.

@hanqing0521
Copy link

now, you can set

let g:completor_tex_omni_trigger = g:vimtex#re#deoplete

@kiryph
Copy link
Author

kiryph commented Mar 21, 2018

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants