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

Enabling automatic triggering of relevant completion suggestions for snippets placeholder positions #1500

Open
TryerGit opened this issue Oct 22, 2022 · 0 comments

Comments

@TryerGit
Copy link

I use UltiSnips in conjunction with mucomplete and VimTeX for autocompletion in .tex files. What I would like to have is automatically triggering of completion suggestions based on context of a snippet placeholder's cursor position. An example follows:

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.

PS: The official response from VimTeX seems to be that it is not possible from within VimTeX to trigger such snippet placeholder contextual completion. See here. I am unsure if it is possible via UltiSnips or mucomplete. I have raised a request for assistance from mucomplete folks as well. See here

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

1 participant