How to set up Math Context Snippets in VSCode?

I tried to set up some snippets, that make inputing typst code faster which is always nice, but necessary for writing in lectures. The original idea came from this blogpost and was for LaTeX.

I did find this blogpost which seems to do exactly what I want: it told me how to adapt this to Typst and VSCode. But setting this up, it didn’t work. The snippets outside of the math context work, but the ones inside the math context do not work.

Has anyone got this to work? Is there another way of creating context sensitive auto expanding snippets in vscode?

The reason the initial code did not work was because the contexts where defined wrong.
The correct contexts are:

function math(context) { return context.scopes.some(s => s.startsWith("markup.math.typst"));}
function comment(context) {return context.scopes.some(s => s.startsWith("comment"));}
function code(context) {return context.scopes.some(s => s.startsWith("string.other.raw.typst") || s.startsWith("markup.raw.block.typst"));}

You can find the correct context by using the command > Inspect Editor Tokens and Scopes and look at the textmate scopes.