v_g_CTRL-G allows you to select some text and then see some basic info about your selection, such as how many words you've selected.
Loading vimtex breaks this functionality: pressing v_g_CTRL-G seems to very quickly print the relevant info, but then it immediately disappears, way too quickly to read what it says.
I can confirm that after disabling vimtex, there is no issue.
A minimal vimrc file:
set nocompatible
let &rtp = '~/.vim/bundle/vimtex,' . &rtp
let &rtp .= ',~/.vim/bundle/vimtex/after'
filetype plugin indent on
syntax enable
A minimal mwe.tex file:
\documentclass{minimal}
\begin{document}
Hello World!
\end{document}
Run vim -u vimrc mwe.tex, visually select the word Hello, and press g_CTRL-G.
Expected behavior: Print the following for at least a few seconds.
Selected 1 of 4 Lines; 1 of 5 Words; 5 of 70 Bytes
Actual behavior: Info disappears immediately.
I believe this is caused by the 50ms popup menu check timer. With the MWE you can call timer_stop(1) to verify the behavior goes away. I guess timers clear certain messages even when they don't do anything. For a few reasons, match-up never seemed to have the issue #493 which led to that hack and does not require a constant timer.
A possible workaround is to use my plugin match-up for the purpose of highlighting matches instead of vimtex's built-in one (see discussion here), although I admit it has much greater effects than just this, so it's not appropriate for everyone.
Interesting. I think @andymass is correct that this happens because of a timer loop. I think @andymass's plugin is good, and so it is a viable choice to use that instead of vimtex's built in match highlighter.
I've added the minimal example. I can confirm the bug with Vim, but it works as expected in neovim. I also confirm that the problem is due to the timer, regardless of what the timer callback actually does.
My understanding is that this is a bug in Vim internals, not with vimtex. There are two working "solutions": Use neovim or use @andymass's plugin. I will not be able to solve this bug myself, and so I am deciding to close the issue as won't fix. Sorry, and I hope someone might create a minimal example and open an issue with the Vim devs.
Thanks, both. matchup looks like a very nice plugin, which I hadn't known about. I've just switched over.
No problem, and I'm sorry about the minor inconvenience.
I've found that when using matchup, my cursor movement is seriously delayed, even on a relatively small paper (6 page report), and even after adding
let g:matchup_matchparen_deferred = 1
So, I think I will just stick with vimtex's built-in matching, and if I need v_g_CTRL-G, I will just
call timer_stop(1)
or maybe make a keybinding that toggles
call timer_pause(1, 1)
and
call timer_pause(1, 0)
or something.
A third option is to switch to neovim, where it seems everything works as expected.
True. I may at some point, but just don't have the time right now -- too many projects that need finishing without any major disruption/change in my workflow. Perhaps in August, once things settle down a bit.
Anyway, thanks again.
No problem. I hope things work out well.
I've updated to use TextChangedP when possible, since this should improve the latency somewhat (I think) and avoid running the callback loop in the background when idle. I think this should also solve the present issue as long as you use a recent Vim version.
Can confirm this resolves the issue -- thanks!
Most helpful comment
I've added the minimal example. I can confirm the bug with Vim, but it works as expected in neovim. I also confirm that the problem is due to the timer, regardless of what the timer callback actually does.
My understanding is that this is a bug in Vim internals, not with vimtex. There are two working "solutions": Use neovim or use @andymass's plugin. I will not be able to solve this bug myself, and so I am deciding to close the issue as
won't fix. Sorry, and I hope someone might create a minimal example and open an issue with the Vim devs.