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

On automatic triggering of relevant completion suggestions via snippets #2527

Closed
TryerGit opened this issue Oct 22, 2022 · 3 comments
Closed

Comments

@TryerGit
Copy link

I have the following .vimrc

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'
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
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 . '$' } }

Consider the following .tex file:

\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}

I have the following snippets via UltiSnips:

snippet refe "Refer Equation" w
(\ref{eq:$1})$0
endsnippet

On typing refe<SnippetTrigger>, one should get:

(\ref{eq:|}) where | denotes the cursor in insert mode. I was hoping that when this happens, automatically, all of the equation labels of the .tex file whose labels start with eq: are displayed in a popup for automatic completion. (Note, this is after ensuring that the .aux file resides in the folder following one compilation as answered here)

However, this does not happen. The automatic triggering happens only if the user manually types in \ref{| individually that the triggering happens.

Please see explanatory video/gif of the above at : https://imgur.com/a/3attCKA

Is this expected behavior or is there a setting to have automatic completion suggestions triggered even if the cursor is at a placeholder position within a snippet?

Thank you.

@lervag
Copy link
Owner

lervag commented Oct 22, 2022

Thanks; this is harder to help with. I believe you may be in more luck asking at either the Ultisnips repo or at MuComplete. I can confirm I have the same "issue" with nvim-cmp (another autocomplete engine) and UltiSnips.

By the way, you probably want \eqref{...} instead of \ref here. You may also be interested in checking out the package cleveref. I strongly recommend it!

@TryerGit
Copy link
Author

Thanks. I will checkout cleveref.

@lervag
Copy link
Owner

lervag commented Oct 22, 2022

No problem. And feel free to link issues if you should open a related issue another place!

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