自定义VSCode语法高亮问题:插值字符串外层括号着色异常
HoneyC语言VSCode语法高亮:插值字符串外层{}着色问题
我正在为自定义语言HoneyC开发VSCode语法高亮功能,核心问题是:实现插值字符串的高亮时,无法为外层的括号({})设置正确的着色,达不到预期效果。
相关配置文件
honeyc.tmLanguage.json
{ "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", "name": "HoneyC", "patterns": [ { "include": "#keywords" }, { "include": "#strings" }, { "include": "#comments" }, { "include": "#constants" }, { "include": "#numbers" }, { "include": "#variables" }, { "include": "#functions" }, { "include": "#objects" }, { "include": "#enums" }, { "include": "#staticVariables" } ], "repository": { "keywords": { "patterns": [ { "name": "keyword.control.honeyc", "match": "\\b(obj|enum|func|in|while|for|if|else|or|and|this|var|val|import)\\b" } ] }, "strings": { "name": "string.quoted.double.honeyc", "begin": "\"", "end": "\"", "patterns": [ { "name": "constant.character.escape.honeyc", "match": "\\\\." }, { "name": "meta.interpolation.honeyc", "begin": "\\{", "end": "\\}", "patterns": [ { "include": "#keywords" }, { "include": "#constants" }, { "include": "#numbers" }, { "include": "#variables" }, { "include": "#functions" }, { "include": "#staticVariables"} ] } ] }, "comments": { "patterns": [ { "name": "comment.block.honeyc", "begin": "/#", "end": "#/" }, { "name": "comment.line.honeyc", "match": "#.*$" } ] }, "constants": { "match": "\\b(?:true|false|null)\\b", "name": "constant.language.honeyc" }, "numbers": { "match": "(?x) # turn on extended mode\n -? # an optional minus\n (?:\n 0 # a zero\n | # ...or...\n [1-9] # a 1-9 character\n \\d* # followed by zero or more digits\n )\n (?:\n (?:\n \\. # a period\n \\d+ # followed by one or more digits\n )?\n (?:\n [eE] # an e character\n [+-]? # followed by an option +/-\n \\d+ # followed by one or more digits\n )? # make exponent optional\n )? # make decimal portion optional", "name": "constant.numeric.json" }, "variables": { "match": "\\b([a-z_][a-zA-Z_]*)\\b(?!\\s*\\()", "name": "variable.other.honeyc" }, "functions": { "match": "\\b([a-zA-Z_]+)\\b(?=\\s*\\()", "name": "entity.name.function.honeyc" }, "objects": { "match": "(?<=\\b(?:obj|enum)\\s+)[a-zA-Z_]+\\b", "name": "support.class.object.honeyc" }, "staticVariables": { "match": "\\b(?!obj\\s+|enum\\s+)([A-Z][a-zA-Z_]*)\\b", "name": "constant.language.honeyc" } }, "scopeName": "source.hc" }
language-configuration.json
{ "comments": { // // symbol used for single line comment. Remove this entry if your language does not support line comments "lineComment": "#", // symbols used for start and end a block comment. Remove this entry if your language does not support block comments "blockComment": [ "/#", "#/" ] }, // symbols used as brackets "brackets": [ ["{", "}"], ["[", "]"], ["(", ")"] ], // symbols that are auto closed when typing "autoClosingPairs": [ ["{", "}"], ["[", "]"], ["(", ")"], ["\"", "\""], ["'", "'"] ], // symbols that can be used to surround a selection "surroundingPairs": [ ["{", "}"], ["[", "]"], ["(", ")"], ["\"", "\""], ["'", "'"] ] }
仓库信息
Github仓库:Burn1ngShade/HoneyCLanguageFeatures
效果对比
预期着色效果

实际着色效果

内容的提问来源于stack exchange,提问作者Isaac Honeyman
相关产品推荐
相关产品推荐

