mafap
mafap

Reputation: 391

TextMate grammar not having any matches on VS Code

I am writing a TextMate grammar to extend the syntax highlighting capabilities on Markdown language using Visual Studio Code. The expected outcome is something like what is achieved with Fabio's vscode-highlight, but I was looking for something more 'simple', without having the need to install or create an extension.

Already did lots of research but can't get any matches when inspecting the scope. Any suggestions? As of now, my files are:

./package.json
{
    "name": "name123",
    "description": "desc123",
    "publisher": "me",
    "version": "0.0.1",
    "engines": {
        "vscode": "^1.0.0"
    },
    "contributes": {
        "grammars": [{
            "language": "markdown",
            "scopeName": "text.html.markdown",
            "path": "./syntaxes/markdown.tmLanguage.json"
        }]
    }
}
./syntaxes/markdown.tmLanguage.json
{
  "scopeName": "text.html.markdown",
  "patterns": [
    { "include": "#headings" }],
  "repository": {
    "headings": {
      "patterns": [
        { "include": "#symbol" },
        { "include": "#text" }]},
        "symbol": {
          "match": "*s2",
          "name": "symbol.letter.number.headings.md" },
        "text": {
          "match": "Description 12345",
          "name": "text.description.headings.md" }
  }
}

Upvotes: 0

Views: 1687

Answers (1)

Gama11
Gama11

Reputation: 34138

In markdown files, there is a regex error logged to the dev console:

ERR target of repeat operator is not specified: Error: target of repeat operator is not specified
    at Object.createOnigScanner (c:\Program Files\Microsoft VS Code\resources\app\node_modules.asar\vscode-textmate\release\main.js:58:24)
    at Grammar.createOnigScanner (c:\Program Files\Microsoft VS Code\resources\app\node_modules.asar\vscode-textmate\release\main.js:2466:30)
    [...]

The problem is the *s2 regex. I'm not sure what exactly you were trying to match there, but there has to be some character that should be repeated before *.

Your other scope matches as expected withsymbol removed to avoid the error:

Upvotes: 1

Related Questions