Feature "Symbol groups", and more changes. #418
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds a new setting called "Symbol groups", Here you can, much like how snippet variables work, create different symbol groups which is parsed into Snippet Variables and another new setting that I will talk about in a bit.
As an example if you in the symbol groups setting have:
{
"{GREEK}": "alpha|beta|gamma"
}
And then in the snippet variables setting have:
{
"${GREEK}": "{GREEK}|Gamma|delta|..."
"${OTHER_SNIPPET_VARIABLE}": "{GREEK}|sin|cos"
}
Then that would be the exact same as writing:
{
"${GREEK}": "alpha|beta|gamma|Gamma|delta|..."
"${OTHER_SNIPPET_VARIABLE}": "alpha|beta|gamma|sin|cos"
}
This allows for more detailed descriptions of snippet variables, which might even only be used at one location in the actual snippets.
I have made changes to default_snippets.js, default_snippet_variables.js and added default_symbol_groups.js to showcase how this new system improves upon the old one.
Before I had issues with the old default snippet variables, as they where in no way descriptive of what they actually did, and maybe you would want a specific symbol in one of the cases where it uses "${SYMBOL}" but not in the other. But I could also see how in the old system it would have been really cluttered to split them. The ${GREEK}: "{GREEK}" default snippet variable I have mainly kept to show that it's allowed to call a snippet variable value "the same" as the symbol groups.
Another reason why I wanted to build this system is that it annoyed me, to a reasonable degree, that in the autofraction.ts code there was a system that made greek symbols also come under the fractions. E.g
"\alpha a/b" -> "\frac{\alpha a}{g}" which is a great system, but it was hardcoded to only greek symbols, so a new setting I have made called "Included symbols", now allows you to define which symbols this would work for. This setting will also use symbol groups
By default I have set it to:
{GREEK}|{SYMBOL}
Which means that all of the symbols in those two symbol groups will allow for this same functionality.
I have also made a few other changes such making the snippet variable also work in the
replacementof a snippet, but only if it's a function, by default this is used in a snippet which takes care of auto letter subscript.The UI of the snippet variables, and symbol groups, settings now look better, it's close to how the snippets editor looks, with a few minor changes. Under the snippet variables editor, I have also included a preview button, which allows you to see how the snippet variables actually look, after symbol groups have been inserted.