language extension project does not seem to load grammar (no grammar provided message)
Asked Answered
A

2

8

Im trying to create a simple language extension for visual studio code. I used the "yo code" to generate a language support extension. After adding my Language name, id, extension and etc, I keep getting this message "no grammar provided for < source. arc" when running the tm scope inspector in the extension debugging host even though vscode recognized the language.

error

Not sure what i can try at this point since the sample should work right off the bat

archsim.tmLanguage.json:

{
    "name": "ArchsimC",
    "scopeName": "source.arc",
    "patterns": [
        {
            "include": "#keywords"
        },
        {
            "include": "#strings"
        }
    ],
    "repository": {
        "keywords": {
            "patterns": [
                {
                    "name": "keyword.control.archsimc",
                    "match": "\\b(if|while|for|return)\\b"                  
                },
            ]
        },
        "strings": {
            "name": "string.quoted.double.archsimc",
            "begin": "\"",
            "end": "\"",
            "patterns": [
                {
                    "name": "constant.character.escape.archsimc",
                    "match": "\\\\."
                }
            ]
        }
    }
}

package.json:

{
    "name": "languagetest",
    "displayName": "LanguageTest",
    "description": "language server test",
    "version": "0.0.1",
    "engines": {
        "vscode": "^1.29.0"
    },
    "categories": [
        "Programming Languages"
    ],
    "contributes": {
        "languages": [
            {
                "id": "archsimc",
                "aliases": [
                    "ArchsimC",
                    "archsimc"
                ],
                "extensions": [
                    ".arc"
                ],
                "configuration": "./language-configuration.json"
            }
        ],
        "grammars": [
            {
                "language": "archsimc",
                "scopeName": "source.arc",
                "path": "./syntaxes/archsimc.tmLanguage.json"
            }
        ]
    }
}

test.arc

if(something)
{
    return;
}

by running inspect TM scope on the "if" should point to the tmLanguage file based on what i have seen in vscode documentation.

Any ideas on what is the issue here and if im doing something wrong?

Aide answered 15/5, 2019 at 6:28 Comment(0)
N
0

I would suggest double-checking the property contributes.grammars.path to see if it is pointing to the correct place, if the file name is correct, and so on.

In my case I had moved the file around. Taking your excerpt as base, I changed from this:

"path": "./syntaxes/archsimc.tmLanguage.json"

To this:

"path": "./src/syntaxes/archsimc.tmLanguage.json"

So it could work properly.

Nock answered 8/8, 2023 at 13:4 Comment(0)
J
0

You have a trailing comma in "keywords": {}

VSCode JSON TextMate does not support trailing commas or C-style comments

The file will fail to parse and won't be assigned to your language.
Hence the no grammar error

trailing comma

Jasonjasper answered 7/9, 2024 at 20:34 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.