-
Notifications
You must be signed in to change notification settings - Fork 24
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
Implement context
matching
#6
Comments
Apparently scope-info is not maintained anymore, so getting scope information is still blocked on microsoft/vscode#580. |
I have exactly the same use-case as @medwatt in #19 - implementing @gillescastel 's snippets in vscode. Other extensions still use scopes via vscode-textmate see example here: restore-scope. Can we not use the vscode-textmate module in this extension? Particularly interested in math scopes inside markdown. |
You might want to take a look at the LaTeX-Utilities VSCode extension that implemented context matching for math mode in latex. It works pretty well. See their documentation about it. |
I really do think that latex snippets is the killer application this extension, though. Almost all of my snippets relate to latex (well, Katex in markdown), and it's really annoying when they trigger outside of a math context. Similarly, I've had to somewhat cripple some of my snippets to make them trigger only in a (likely) math context and often that makes my snippets less useful, and need more key presses. |
@draivin What about using their (LaTeX-Utilities) parsing logic in your extension ? |
Or, to make it more generic, maybe use the same logic as the vscode extension markdown+math uses (extension used by 160k people). |
I think if we are really going down the custom parser route, we should at least try to do it as the late I'll think some more about this, and see how viable it would be to resurrect that extension. |
After considering this I have been reminded that when using Markdown+Math, the editor does not add a scope to display math if it has a line break. I presume this is a limitation of vscode? Note that math does render in the preview correctly. See This is recognised (a little unclearly) in the readme under "Is formula highlighting broken?" https://github.com/goessner/mdmath/blob/master/readme.md So, for instance, Markdown+Math will apply a math scope for
But Markdown+Math will not apply a math scope for the below, even though it is valid, and renders correctly in preview.
So, in conclusion, we cannot currently rely on other extensions adding the correct scope. This may be due to a limitation of vscode in applying a scope. But, for now, if we are just reading the scope from the editor (by resurrecting scope-info) sometimes we will be writing math but the scope will not reflect this. However, I'm not going to let the perfect be the enemy of the good. If we can have hsnips use the existing scopes in the editor, this will still be MUCH better than the current situation. |
This is not an issue on vscode's side, the problem (as is the case with all this scope stuff) is that You can see that in the example you posted, vscode has the correct scope information (you can check the scope information by running the command |
Inside the math of
I get the scope as meta.paragraph.markdown I have vscode version 1.55.2 (Universal) Is yours coming from a different extension? Or are you using the latest vscode (I had to downgrade to last months)? |
Probably the extension that is supplying the markdown syntax definition files for mine is different than yours, (I think the extension supplying the syntax files in my case is "Markdown All in One", as seen here). |
That's correct. I have enabled "Markdown All in One" and now I get support.function.katex So, OK, we can make vscode recognise math scopes correctly. OK, so, I'm now all in favour of resurrecting scope-info! |
Hey guys, the latest version of Here is an example of how to use the new feature to expand the
|
Yes it seems to work well for me! Needs to be more tested though. |
I don't know if I should open a new issue, but I found a weird behavior in the new version: For some reasons, this is not working anymore:
If the trigger is not ending with a |
You should probably create a new issue, but I can't reproduce the problem with any of the 3 examples. |
Implement
context
as in UltiSnips, as can be seen in the UltiSnips manual at the sectionUltiSnips-custom-context-snippets
.Maybe look into scope-info so we can provide that information to the context matchers.
The text was updated successfully, but these errors were encountered: