1

I have a problem with Visual Studio Code custom syntax highlighting. I have made a extension using yo code, put it in %userprofile%/.vscode/extensions, restarted Visual Studio Code, but it's not highlighting any words, but at the bottom it says it's using my syntax highlighter. This is my tmLanguage.json:

{
    "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
    "name": "Instructions ASM",
    "patterns": [
        {
            "include": "#keywords"
        },
        {
            "include": "#typewords"
        },
        {
            "include": "#strings"
        },
        {
            "include": "#numbers"
        },
        {
            "include": "#variables"
        },
        {
            "include": "#comments"
        },
        {
            "include": "#sections"
        }
    ],
    "repository": {
        "keywords":{
            "patterns": [
                {
                    "name": "keyword",
                    "match": "(mov|xor|and|or|int|jmp|con)"
                }
            ]
        },
        "typewords": {
            "patterns": [
                {
                    "name": "keyword.control",
                    "match": "(db|dw|dd|resb|resw|resd|eq|byte|word|doubleword)"
                }
            ]
        },
        "strings": {
            "patterns": [
                {
                    "name": "string",
                    "match": "(\".*\")|('.')"
                }
            ]
        },
        "numbers": {
            "patterns": [
                {
                    "name": "constant.numeric",
                    "match": "(0[xX][a-fA-F0-9]{1,8})|(\\d+)|(0[bB][0-1]{1,64})"
                }
            ]
        },
        "variables": {
            "patterns": [
                {
                    "name": "variable",
                    "match": "$[a-zA-Z0-9_-.]{1,255}"
                }
            ]
        },
        "comments": {
            "patterns": [
                {
                    "name": "comment",
                    "match": ";.*"
                }
            ]
        },
        "sections": {
            "patterns": [
                {
                    "name": "entity.name.class",
                    "match": "(\\.DATA|\\.TEXT|\\.BSS)"
                }
            ]
        }
    },
    "scopeName": "source.1"
}

This is my package.json:

{
    "name": "instruction-assembly",
    "displayName": "Instruction assembly",
    "description": "Code only in instructions - Assembly readable version",
    "version": "0.0.1",
    "engines": {
        "vscode": "^1.54.0"
    },
    "categories": [
        "Programming Languages"
    ],
    "contributes": {
        "languages": [{
            "id": "instructions-asm",
            "aliases": ["Instructions ASM", "instructions-asm"],
            "extensions": [".1"],
            "configuration": "./language-configuration.json"
        }],
        "grammars": [{
            "language": "instructions-asm",
            "scopeName": "source.1",
            "path": "./syntaxes/instructions-asm.tmLanguage.json"
        }]
    }
}

Thanks!

  • what is the full **relative** file path of your Textmate file. Why don't you just launch the extension to try it out, no need to copy and restart – rioV8 Apr 02 '22 at 13:11
  • @rioV8 all files are where yo created them. So it's the same as you see in package.json. And it also doesn't work when I launch the extension. –  Apr 03 '22 at 05:07
  • does the example syntax highlighting work – rioV8 Apr 03 '22 at 08:25
  • @rioV8 yes, example works –  Apr 09 '22 at 09:35
  • then change the example line by line, try after a each small modification until you reach the point where you made a mistake – rioV8 Apr 09 '22 at 10:17

0 Answers0