I am currently trying to develop a VSCode syntax highlighting for my custom language. The main problem im having is that when trying to highlight interpreted strings, I can't figure out how to highlight the outer brackets as done via the language-configuration.json
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 https://github.com/Burn1ngShade/HoneyCLanguageFeatures
If you run editor.action.inspectTMScopes
you'll see that the standard token type
has changed to String
which disables bracket pair highlighting
you can use the scope meta.embedded
to reset the standard token type
back to Other
re-enabling bracket pair highlighting
you can space separate the scopes
if you don't want to combine them