0

我想創建一個新的語言在CPU12彙編語言Visual Studio代碼高亮句法。當我在一個新的.asm文件中使用新語言時,編輯器知道註釋字符是(當我鍵入ctrl-k ctrl-c時,它將分號添加到一行中),但文本是白色而不是默認註釋顏色綠色。我是否需要指定使用默認的vscode主題?如果是這樣,在哪裏?vscode新的語言配置不改變語法顏色

的package.json

{ 
    "name": "cpu12", 
    "displayName": "cpu12", 
    "description": "cpu12", 
    "version": "0.0.1", 
    "publisher": "https://github.com/me", 
    "engines": { 
     "vscode": "^1.15.0" 
    }, 
    "categories": [ 
     "Languages" 
    ], 
    "contributes": { 
     "languages": [{ 
      "id": "cpu12", 
      "aliases": ["CPU12", "cpu12"], 
      "extensions": [".asm",".inc"], 
      "configuration": "./language-configuration.json" 
     }], 
     "grammars": [{ 
      "language": "cpu12", 
      "scopeName": "source.cpu12", 
      "path": "./syntaxes/cpu12.tmLanguage.json" 
     }] 
    } 
} 

語言configuration.json

{ 
    "comments": { 
     // symbol used for single line comment. Remove this entry if your language does not support line comments 
     "lineComment": ";" 
    }, 
    // symbols used as brackets 
    "brackets": [ 
     ["{", "}"], 
     ["[", "]"], 
     ["(", ")"] 
    ], 
    // symbols that are auto closed when typing 
    "autoClosingPairs": [ 
     ["{", "}"], 
     ["[", "]"], 
     ["(", ")"], 
     ["\"", "\""], 
     ["'", "'"] 
    ], 
    // symbols that that can be used to surround a selection 
    "surroundingPairs": [ 
     ["{", "}"], 
     ["[", "]"], 
     ["(", ")"], 
     ["\"", "\""], 
     ["'", "'"] 
    ] 
} 

(我./syntaxes/cpu12.tmLanguage.json是空的。)

+0

考慮https://github.com/heztet/cpu12-vscode /blob/master/syntaxes/cpu12.tmlanguage.json不是空的,我假設你已經找到解決你的問題?請注意[你可以回答你自己的問題](https://stackoverflow.com/help/self-answer)。 – Gama11

+0

謝謝,我不知道我能回答我自己的問題。我把它貼在下面 – heztet

回答

0

的問題實際上是因爲./syntaxes/cpu12.tmLanguage.json是空的。您需要在以.json文件如何着色行指定評論:

./syntaxes/cpu12.tmLanguage.json

{ 
    "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", 
    "name": "cpu12", 
    "scopeName": "source.cpu12", 
    "patterns": [ 
     { 
      "comment": "Line Comments -- Asterisk only works at beginning of line", 
      "match": "((;|^\\*).*$)", 
      "captures": { 
       "1" :{ 
        "name": "comment.line.cpu12" 
       } 
      } 
     } 
    ] 
}