lifepillar / vim-mucomplete

Chained completion that works the way you want!
MIT License
911 stars 18 forks source link

Automatic completion with VimTex #203

Closed TryerGit closed 2 years ago

TryerGit commented 2 years ago

Hello,

My vimrc is thus:

if empty(glob('~/.vim/autoload/plug.vim'))
    silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
        \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
    autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
Plug 'lervag/vimtex'
Plug 'lifepillar/vim-mucomplete'
call plug#end()

set completeopt+=menuone
set completeopt+=noselect
let g:mucomplete#enable_auto_at_startup = 1

let g:mucomplete#can_complete = {}
let g:mucomplete#can_complete.tex = { 'omni': { t -> t =~# g:vimtex#re#neocomplete . '$' } }

I have taken the suggestion for can_complete.tex from https://github.com/lervag/vimtex/blob/master/doc/vimtex.txt with respect to having mucomplete interact with VimTex.

I have the following content in bibfile.bib:

@Article{somekey,
  title     = {A super awesome paper}
}

With this configuration, I am able to have mucomplete work fine for triggering automatic completion suggestion when \cite{ is typed and the option provided is somekey from the bibliography file.

However, on typing \ref{ in the hope of triggering automatic completion suggestions of equation labels in the .tex file, it fails to work.

Please see the animated gif of the .tex file : https://imgur.com/a/XOv167i

Is it possible to help me figure out why this could be the case?

Thank you.


ETA: In case you would like to replicate at your end, here is the content of the .tex file shown in the animated gif:

\documentclass[11pt]{article}

\usepackage{amsmath}

\begin{document}

\begin{alignat}{2}
    \text{ }& asdfasdf              &&\quad\nonumber\\
    \text{ }&89999\times 45\leq 88  &&\quad \forall\label{eq:1}\\
        &abc                    &&\quad\exists\label{eq:okay}\\
        &\times x           &&\quad\forall\nonumber\\
        &abcd                   &&\quad\nonumber
\end{alignat}

\bibliographystyle{apalike}
\bibliography{bibfile.bib}

\end{document}

Output of :echo g:vimtex#re#neocomplete is

\v\\%(%(\a*cite|Cite)\a*\*?%(\s*\[[^]]*\]){0,2}\s*\{[^}]*|%(\a*cites|Cites)%(\s*\([^)]*\)){0,2}%(%(\s*\[[^]]*\]){0,2}\s*\{[^}]*\})*%(\s*\[[^]]*\]){0,2}\s*\{[^}]*|bibentry\s*\{[^}]*|%(text|block)cquote\*?%(\s*\[[^]]*\]){0,2}\s*\{[^}]*|%(for|hy)\w*cquote\*?\{[^}]*}%(\s*\[[^]]*\]){0,2}\s*\{[^}]*|defbibentryset\{[^}]*}\{[^}]*|\a*ref%(\s*\{[^}]*|range\s*\{[^,}]*%(}\{)?)|hyperref\s*\[[^]]*|includegraphics\*?%(\s*\[[^]]*\]){0,2}\s*\{[^}]*|%(include%(only)?|input|subfile)\s*\{[^}]*|([cpdr]?(gls|Gls|GLS)|acr|Acr|ACR)\a*\s*\{[^}]*|(ac|Ac|AC)\s*\{[^}]*|includepdf%(\s*\[[^]]*\])?\s*\{[^}]*|includestandalone%(\s*\[[^]]*\])?\s*\{[^}]*|%(usepackage|RequirePackage|PassOptionsToPackage)%(\s*\[[^]]*\])?\s*\{[^}]*|documentclass%(\s*\[[^]]*\])?\s*\{[^}]*|begin%(\s*\[[^]]*\])?\s*\{[^}]*|end%(\s*\[[^]]*\])?\s*\{[^}]*|\a*)

TryerGit commented 2 years ago

This issue was resolved by the maintainer of VimTex. See here