Using $0 in snippets

I have a language server hooked up to my codemirror 6 editor and I’m having issues getting $0, $1, … to work in snippets. Snippets using ${value} are working as expected but not the others. Has anyone implemented this before?

The docs are pretty clear that the syntax is ${0}, not $0.

Got it. Just wasn’t sure if both are supported since it’s standard for language servers and other snippets to use both.

For anyone who may encounter this in the future I’m just using this function to convert snippets to the CodeMirror compatible format.

function convertSnippetFormat(snippetTemplate: string) {
  return snippetTemplate.replace(/\$(\d+)/g, (_, number) => {
    // LSP $0 is supposed to be the last tab stop so we set it to a large number
    if (number === '0') {
      return '${999}';
    }
    return `\${${number}}`;
  });
}