SirVer / ultisnips

UltiSnips - The ultimate snippet solution for Vim. Send pull requests to SirVer/ultisnips!
GNU General Public License v3.0
7.55k stars 691 forks source link

Vimtex quickfix menu breaks snippet #1527

Open kayprish opened 1 year ago

kayprish commented 1 year ago

If one is currently typing out a snippet in a TeX file with UltiSnips, it will often stop working mid-writing if Vimtexs quickfix menu pops-up. The most common and annoying example is when writing using an environment snippet

Expected behavior: When using a snippet such as this one:

snippet env "New environment" bA
\begin{$1}
    ${0:${VISUAL:}}
\end{$1}
endsnippet

once you begin typing an environment, such as say, itemize, and jumping with JumpForwardTrigger, you get this:

\begin{itemize}
    "your cursor is now here"
\end{itemize}

and now you can continue typing in your snippet.

Actual behavior: as you start to type, if the LaTeX document compiles in the meanwhile, it will likely produce an error, which will pop up in the quickfix menu below, after this, your snippet no longer works, what you type in the \begin{} is no longer reproduced in the \end{}, and you can no longer use the jump key to jump to the next tabstop. The end result is your text looking something like this:

\begin{itemize}

\end{ite}

the end command is broken and you have to reach down to fix it manually.

Steps to reproduce In order for your file in Vimtex to compile after every edit, you need something like this in your vimrc:

autocmd TextChanged,InsertLeave *.tex silent update

Also, obviously, you need Vimtex installed for the continuous compilation, and, while you're editing, you need to turn continuous compilation on with "localleader" ll.

Extra note It should be noted that this error will always happen when you start writing an environment, because at some point while you're writing you will have an environment name such as ite, which is incomplete, and LaTeX will complain that this environment doesn't exist.

Workarounds


Plug 'lervag/vimtex' Plug 'SirVer/ultisnips'

let g:UltiSnipsSnippetDirectories = [$HOME.'/.vim/UltiSnips'] call plug#end()

autocmd TextChanged,InsertLeave *.tex silent update

ftplugin/tex.vim:

let g:vimtex_quickfix_mode = 2 let g:vimtex_quickfix_open_on_warning = 0