kdl-org.github.io/kdl.tmLanguage.json

228 lines
5.8 KiB
JSON

{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"comment": "Some of these patterns are taken straight from rust-analyzer: https://github.com/rust-lang/vscode-rust/blob/master/rust-analyzer/editors/code/rust.tmGrammar.json. Some was also taken from https://github.com/arm32x/vscode-sdlang/blob/master/syntaxes/sdlang.tmLanguage.json",
"name": "kdl",
"patterns": [
{
"include": "#forbidden_ident"
},
{
"include": "#null"
},
{
"include": "#boolean"
},
{
"include": "#float_keyword"
},
{
"include": "#float_fraction"
},
{
"include": "#float_exp"
},
{
"include": "#decimal"
},
{
"include": "#hexadecimal"
},
{
"include": "#octal"
},
{
"include": "#binary"
},
{
"include": "#raw-string"
},
{
"include": "#string_multi_line"
},
{
"include": "#string_single_line"
},
{
"include": "#block_comment"
},
{
"include": "#block_doc_comment"
},
{
"include": "#slashdash_block_comment"
},
{
"include": "#slashdash_comment"
},
{
"include": "#slashdash_node_with_children_comment"
},
{
"include": "#slashdash_node_comment"
},
{
"include": "#line_comment"
},
{
"include": "#attribute"
},
{
"include": "#node_name"
},
{
"include": "#ident_string"
}
],
"repository": {
"float_fraction": {
"comment": "Floating point literal (fraction)",
"name": "constant.numeric.float.rust",
"match": "\\b([0-9\\-\\+]|\\-|\\+)[0-9_]*\\.[0-9][0-9_]*([eE][+-]?[0-9_]+)?\\b"
},
"float_exp": {
"comment": "Floating point literal (exponent)",
"name": "constant.numeric.float.rust",
"match": "\\b[0-9][0-9_]*(\\.[0-9][0-9_]*)?[eE][+-]?[0-9_]+\\b"
},
"decimal": {
"comment": "Integer literal (decimal)",
"name": "constant.numeric.integer.decimal.rust",
"match": "\\b[0-9\\-\\+][0-9_]*\\b"
},
"hexadecimal": {
"comment": "Integer literal (hexadecimal)",
"name": "constant.numeric.integer.hexadecimal.rust",
"match": "\\b0x[a-fA-F0-9][a-fA-F0-9_]*\\b"
},
"octal": {
"comment": "Integer literal (octal)",
"name": "constant.numeric.integer.octal.rust",
"match": "\\b0o[0-7][0-7_]*\\b"
},
"binary": {
"comment": "Integer literal (binary)",
"name": "constant.numeric.integer.binary.rust",
"match": "\\b0b[01][01_]*\\b"
},
"forbidden_ident": {
"name": "invalid.illegal.kdl.bad-ident",
"match": "(?<!#)(?:true|false|null|nan|[-]?inf)"
},
"node_name": {
"name": "entity.name.tag",
"match": "((?<={|;)|^)\\s*(?![/\\\\{\\}#;\\[\\]\\=])[<>:\\w\\-_~,'`!\\?@\\$%^&*+|.\\(\\)]+\\d*[<>:\\w\\-_~,'`!\\?@\\$%^&*+|.\\(\\)]*"
},
"attribute": {
"name": "entity.other.attribute-name.kdl",
"match": "(?![/\\\\{\\}#;\\[\\]\\=])[<>:\\w\\-_~,'`!\\?@\\$%^&*+|.\\(\\)]+\\d*[<>:\\w\\-_~,'`!\\?@\\$%^&*+|.\\(\\)]*(=)",
"captures": {
"1": {
"name": "punctuation.separator.key-value.kdl"
}
}
},
"ident_string": {
"name": "string.unquoted",
"match": "(?![/\\\\{\\}#;\\[\\]\\=])[<>:\\w\\-_~,'`!\\?@\\$%^&*+|.\\(\\)]+\\d*[<>:\\w\\-_~,'`!\\?@\\$%^&*+|.\\(\\)]*"
},
"float_keyword": {
"name": "constant.language.other.kdl",
"match": "#nan|#inf|#-inf"
},
"null": {
"name": "constant.language.null.kdl",
"match": "#null"
},
"boolean": {
"name": "constant.language.boolean.kdl",
"match": "#true|#false"
},
"string_single_line": {
"name": "string.quoted.double.kdl",
"begin": "\"",
"end": "\"",
"patterns": [
{
"name": "constant.character.escape.kdl",
"match": "\\\\(:?[nrtbfs\\\\\"]|u\\{[a-fA-F0-9]{1,6}\\})"
}
]
},
"string_multi_line": {
"name": "string.quoted.triple.kdl",
"begin": "\"\"\"",
"end": "\"\"\"",
"patterns": [
{
"name": "constant.character.escape.kdl",
"match": "\\\\(:?[nrtbfs\\\\\"]|u\\{[a-fA-F0-9]{1,6}\\})"
}
]
},
"raw-string": {
"name": "string.quoted.other.raw.kdl",
"begin": "(#+)(\"{3,1})",
"end": "\\2\\1"
},
"block_doc_comment": {
"comment": "Block documentation comment",
"name": "comment.block.documentation.kdl",
"begin": "/\\*[\\*!](?![\\*/])",
"end": "\\*/",
"patterns": [
{
"include": "#block_doc_comment"
},
{
"include": "#block_comment"
}
]
},
"block_comment": {
"comment": "Block comment",
"name": "comment.block.kdl",
"begin": "/\\*",
"end": "\\*/",
"patterns": [
{
"include": "#block_doc_comment"
},
{
"include": "#block_comment"
}
]
},
"line_comment": {
"comment": "Single-line comment",
"name": "comment.line.double-slash.kdl",
"begin": "//",
"end": "$"
},
"slashdash_comment": {
"name": "comment.block.slashdash.kdl",
"comment": "Slashdash inline comment",
"begin": "(?<!^)/-",
"end": "\\s"
},
"slashdash_node_comment": {
"name": "comment.block.slashdash.kdl",
"comment": "Slashdash node comment",
"begin": "(?<=^)/-",
"end": "(?:;|(?<!\\\\)$)"
},
"slashdash_node_with_children_comment": {
"name": "comment.block.slashdash.kdl",
"comment": "Slashdash node comment",
"begin": "(?<=^)/-[^{]+{",
"end": "\\}"
},
"slashdash_block_comment": {
"name": "comment.block.slashdash.kdl",
"comment": "Slashdash block comment",
"begin": "/-(?:\\s*){",
"end": "}"
}
},
"scopeName": "source.kdl"
}