-
Notifications
You must be signed in to change notification settings - Fork 391
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
Vimtex API function that returns name of the enclosing environment, command or region #1981
Comments
Yes. There are couple of relevant functions:
|
@lervag Thanks!! The way I am able to distinguish whether currently cursor is in a command, or environment is to first check the command it is in, if the command is One observation: I think P.S. I wonder the reason scrolling with VimTeX is slow is because VimTeX evaluates this (or other information) for all cursor moves? I think there could be an opening for performance improvement? Like for instance, instead of evaluating a bunch of information when cursor moves, VimTeX could evaluate what it needs when that information is needed (like in a VimTeX function). The rationale behind this being, most of the time users are not using VimTeX functions & are doing regular editing of code. Given regular editing involves a lot of scrolling, not slowing down scrolling is always a good idea. |
I think a simpler solution that should work is to compare the positions of the result of
I'm not fully sure what you mean. But perhaps there's a spurious
The slowdown is probably caused by the matchparen functionality. You can check that by disabling it with Notice that this is also documented (see e.g. |
Thanks, will try updating my example with the functions you mention.
Yep that's what I think is going on. I couldn't find anything in my function
Thanks!! a lot, that fixed scrolling slowness completely!! |
Ok, I'll look into it and see if I can find the culprit :)
Happy to hear it. By the way: I suggest you read the Github Markdown specs. For inline code, it is sufficient to use single backquotes, i.e. |
I've looked into it and I can't find anything that should echo anything here. If you can reproduce it reliably, please feel free to open a new issue. |
Is there a Vimtex API function that returns the name of enclosing environment, or command? So for a document like the following:
the returned names would be like: documentclass, when the cursor is in the
[<optionlist>]{<argument>}
part of\documentclass
, and so on.Also, in any region before
\begin{document}
, while outside a command or environment, the returned string would bepreamble
. And anywhere after\end{document}
would bepostamble
.Motivation: Such a function can then be used to set custom completion dictionary based on the name of environment/command. That way user can have a one dictionary per tex enviornment/command to know what key-values it can accept in the optional argument. Not the most robust, but good enough to do the job.
So for instance, if environment
helloworld
can take a comma separated list consisting ofkey=val
, and if the valid keys arewidth=<width>
,height=<height>
, hitting someC-x C-<something>
would bring up completion list that has the valid key names forhelloworld
environment.PS! It would be users responsibility to maintain dictionary of valid
key
names for their environments/commands, and perhaps share it with world while releasing a latex package with instructions on how users can use this feature with Vim & Vimtex.The text was updated successfully, but these errors were encountered: