622 lines
14 KiB
JSON
622 lines
14 KiB
JSON
{
|
|
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
|
|
"name": "mist",
|
|
"scopeName": "source.mist",
|
|
"patterns": [
|
|
{
|
|
"include": "#include"
|
|
},
|
|
{
|
|
"include": "#comments"
|
|
},
|
|
{
|
|
"include": "#strings"
|
|
},
|
|
{
|
|
"include": "#attributes"
|
|
},
|
|
{
|
|
"include": "#macros"
|
|
},
|
|
{
|
|
"include": "#type_declarations"
|
|
},
|
|
{
|
|
"include": "#keywords"
|
|
},
|
|
{
|
|
"include": "#numbers"
|
|
},
|
|
{
|
|
"include": "#lifetimes"
|
|
},
|
|
{
|
|
"include": "#generics"
|
|
},
|
|
{
|
|
"include": "#types"
|
|
},
|
|
{
|
|
"include": "#imports"
|
|
},
|
|
{
|
|
"include": "#modules"
|
|
},
|
|
{
|
|
"include": "#struct_literals"
|
|
},
|
|
{
|
|
"include": "#impl"
|
|
},
|
|
{
|
|
"include": "#method_calls"
|
|
},
|
|
{
|
|
"include": "#field_access"
|
|
},
|
|
{
|
|
"include": "#arrow"
|
|
},
|
|
{
|
|
"include": "#return_arrow"
|
|
},
|
|
{
|
|
"include": "#functions"
|
|
},
|
|
{
|
|
"include": "#path_continuation"
|
|
},
|
|
{
|
|
"include": "#operators"
|
|
},
|
|
{
|
|
"include": "#punctuation"
|
|
},
|
|
{
|
|
"include": "#variables"
|
|
}
|
|
],
|
|
"repository": {
|
|
"include": {
|
|
"patterns": [
|
|
{
|
|
"begin": "(#)\\s*(include)\\b",
|
|
"beginCaptures": {
|
|
"1": {
|
|
"name": "keyword.control.directive.include.mist"
|
|
},
|
|
"2": {
|
|
"name": "keyword.control.directive.include.mist"
|
|
}
|
|
},
|
|
"end": "$",
|
|
"name": "meta.preprocessor.include.mist",
|
|
"patterns": [
|
|
{
|
|
"match": "\"[^\"]*\"",
|
|
"name": "string.quoted.double.include.mist"
|
|
},
|
|
{
|
|
"match": "<[^>]*>",
|
|
"name": "string.quoted.other.lt-gt.include.mist"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"begin": "(#)\\s*(use)\\b",
|
|
"beginCaptures": {
|
|
"1": {
|
|
"name": "keyword.control.directive.include.mist"
|
|
},
|
|
"2": {
|
|
"name": "keyword.control.directive.include.mist"
|
|
}
|
|
},
|
|
"end": ";",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.terminator.statement.mist"
|
|
}
|
|
},
|
|
"name": "meta.preprocessor.include.mist",
|
|
"patterns": [
|
|
{
|
|
"include": "#types"
|
|
},
|
|
{
|
|
"match": "::",
|
|
"name": "punctuation.separator.namespace.mist"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"comments": {
|
|
"name": "comment.line.double-slash.mist",
|
|
"match": "//.*"
|
|
},
|
|
"strings": {
|
|
"name": "string.quoted.double.mist",
|
|
"begin": "\"",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.string.begin.mist"
|
|
}
|
|
},
|
|
"end": "\"",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.string.end.mist"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"match": "\\\\.",
|
|
"name": "constant.character.escape.mist"
|
|
}
|
|
]
|
|
},
|
|
"attributes": {
|
|
"name": "meta.attribute.mist",
|
|
"begin": "#!?\\[",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.attribute.begin.mist"
|
|
}
|
|
},
|
|
"end": "\\]",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.definition.attribute.end.mist"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"include": "$self"
|
|
}
|
|
]
|
|
},
|
|
"macros": {
|
|
"patterns": [
|
|
{
|
|
"begin": "\\b([a-zA-Z_][a-zA-Z0-9_]*)(!)(\\()",
|
|
"beginCaptures": {
|
|
"1": {
|
|
"name": "entity.name.function.macro.mist"
|
|
},
|
|
"2": {
|
|
"name": "keyword.operator.macro.mist"
|
|
},
|
|
"3": {
|
|
"name": "punctuation.parenthesis.begin.mist"
|
|
}
|
|
},
|
|
"end": "\\)",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.parenthesis.end.mist"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"include": "$self"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"begin": "\\b([a-zA-Z_][a-zA-Z0-9_]*)(!)(\\[)",
|
|
"beginCaptures": {
|
|
"1": {
|
|
"name": "entity.name.function.macro.mist"
|
|
},
|
|
"2": {
|
|
"name": "keyword.operator.macro.mist"
|
|
},
|
|
"3": {
|
|
"name": "punctuation.bracket.begin.mist"
|
|
}
|
|
},
|
|
"end": "\\]",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.bracket.end.mist"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"include": "$self"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"begin": "\\b([a-zA-Z_][a-zA-Z0-9_]*)(!)(\\{)",
|
|
"beginCaptures": {
|
|
"1": {
|
|
"name": "entity.name.function.macro.mist"
|
|
},
|
|
"2": {
|
|
"name": "keyword.operator.macro.mist"
|
|
},
|
|
"3": {
|
|
"name": "punctuation.curly.brace.begin.mist"
|
|
}
|
|
},
|
|
"end": "\\}",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.curly.brace.end.mist"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"include": "$self"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"type_declarations": {
|
|
"patterns": [
|
|
{
|
|
"match": "\\b(struct|enum|class|trait|type)\\s+([a-zA-Z_][a-zA-Z0-9_]*)",
|
|
"captures": {
|
|
"1": {
|
|
"name": "storage.type.mist"
|
|
},
|
|
"2": {
|
|
"name": "entity.name.type.mist"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\s+([a-zA-Z_][a-zA-Z0-9_]*)(?=\\s*(?:<[^;(){}]*>)?\\s*\\()",
|
|
"captures": {
|
|
"1": {
|
|
"patterns": [
|
|
{
|
|
"include": "#types"
|
|
}
|
|
]
|
|
},
|
|
"2": {
|
|
"name": "entity.name.function.mist"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"keywords": {
|
|
"patterns": [
|
|
{
|
|
"match": "\\b(true|false)\\b",
|
|
"name": "constant.language.boolean.mist"
|
|
},
|
|
{
|
|
"match": "\\b(if|else|match)\\b",
|
|
"name": "keyword.control.conditional.mist"
|
|
},
|
|
{
|
|
"match": "\\b(for|while|loop|in)\\b",
|
|
"name": "keyword.control.loop.mist"
|
|
},
|
|
{
|
|
"match": "\\b(return|break|continue)\\b",
|
|
"name": "keyword.control.flow.mist"
|
|
},
|
|
{
|
|
"match": "\\b(struct|enum|class|trait|type)\\b",
|
|
"name": "storage.type.mist"
|
|
},
|
|
{
|
|
"match": "\\b(self|super|crate|Super)\\b",
|
|
"name": "variable.language.mist"
|
|
},
|
|
{
|
|
"match": "\\b(let|const|static)\\b",
|
|
"name": "storage.modifier.mist"
|
|
},
|
|
{
|
|
"match": "\\b(pub|mut)\\b",
|
|
"name": "storage.modifier.visibility.mist"
|
|
},
|
|
{
|
|
"match": "\\b(virtual|override)\\b",
|
|
"name": "storage.modifier.virtual.mist"
|
|
},
|
|
{
|
|
"match": "\\b(impl)\\b",
|
|
"name": "keyword.declaration.implementation.mist"
|
|
},
|
|
{
|
|
"match": "\\b(use)\\b",
|
|
"name": "keyword.control.use.mist"
|
|
},
|
|
{
|
|
"match": "\\b(module)\\b",
|
|
"name": "keyword.control.module.mist"
|
|
},
|
|
{
|
|
"match": "\\b(as)\\b",
|
|
"name": "keyword.operator.alias.mist"
|
|
},
|
|
{
|
|
"match": "\\b(dyn)\\b",
|
|
"name": "storage.modifier.dynamic.mist"
|
|
},
|
|
{
|
|
"match": "\\b(fn)\\b",
|
|
"name": "storage.modifier.function.mist"
|
|
},
|
|
{
|
|
"match": "\\b(unsafe)\\b",
|
|
"name": "keyword.control.unsafe.mist"
|
|
},
|
|
{
|
|
"match": "\\b(constructor)\\b",
|
|
"name": "entity.name.function.constructor.mist"
|
|
}
|
|
]
|
|
},
|
|
"numbers": {
|
|
"patterns": [
|
|
{
|
|
"match": "\\b\\d+\\.\\d+\\b",
|
|
"name": "constant.numeric.float.mist"
|
|
},
|
|
{
|
|
"match": "\\b\\d+\\b",
|
|
"name": "constant.numeric.integer.mist"
|
|
}
|
|
]
|
|
},
|
|
"lifetimes": {
|
|
"match": "'[a-zA-Z_][a-zA-Z0-9_]*\\b",
|
|
"name": "storage.modifier.lifetime.mist"
|
|
},
|
|
"generics": {
|
|
"patterns": [
|
|
{
|
|
"begin": "(?<=[a-zA-Z0-9_>])<(?![=<>])",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "punctuation.brackets.angle.mist"
|
|
}
|
|
},
|
|
"end": "(?<!=)>",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.brackets.angle.mist"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"include": "#comments"
|
|
},
|
|
{
|
|
"include": "#strings"
|
|
},
|
|
{
|
|
"include": "#lifetimes"
|
|
},
|
|
{
|
|
"include": "#types"
|
|
},
|
|
{
|
|
"match": "\\b[a-zA-Z_][a-zA-Z0-9_]*\\b",
|
|
"name": "entity.name.type.mist"
|
|
},
|
|
{
|
|
"match": ",",
|
|
"name": "punctuation.separator.mist"
|
|
},
|
|
{
|
|
"match": "[:+]",
|
|
"name": "keyword.operator.mist"
|
|
},
|
|
{
|
|
"include": "#field_access"
|
|
},
|
|
{
|
|
"include": "#path_continuation"
|
|
},
|
|
{
|
|
"include": "#generics"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"types": {
|
|
"patterns": [
|
|
{
|
|
"match": "(?<![A-Za-z])(f32|f64|i128|i16|i32|i64|i8|isize|u128|u16|u32|u64|u8|usize|str|char|bool|void)\\b",
|
|
"name": "storage.type.built-in.primitive.mist"
|
|
},
|
|
{
|
|
"match": "\\b((?:[a-z_][a-zA-Z0-9_]*::)*)([A-Z][A-Za-z0-9_]*)\\b",
|
|
"captures": {
|
|
"1": {
|
|
"name": "entity.name.namespace.mist"
|
|
},
|
|
"2": {
|
|
"name": "entity.name.type.mist"
|
|
}
|
|
},
|
|
"include": "#operators"
|
|
},
|
|
{
|
|
"match": "\\b[A-Z][A-Za-z0-9_]*\\b",
|
|
"name": "entity.name.type.mist"
|
|
}
|
|
]
|
|
},
|
|
"imports": {
|
|
"match": "\\buse\\s+([a-zA-Z_][a-zA-Z0-9_]*(?:\\s*::\\s*[a-zA-Z_][a-zA-Z0-9_]*)*)\\s*;",
|
|
"patterns": [
|
|
{
|
|
"include": "#types"
|
|
}
|
|
],
|
|
"name": "meta.import.mist"
|
|
},
|
|
"modules": {
|
|
"match": "(?:pub\\s+)?\\bmodule\\s+([a-zA-Z_][a-zA-Z0-9_]*)\\s*;",
|
|
"captures": {
|
|
"1": {
|
|
"name": "entity.name.namespace.module.mist"
|
|
}
|
|
}
|
|
},
|
|
"struct_literals": {
|
|
"patterns": [
|
|
{
|
|
"begin": "\\b([A-Z][a-zA-Z0-9_]*)\\s*(\\{)",
|
|
"beginCaptures": {
|
|
"1": {
|
|
"name": "entity.name.type.mist"
|
|
},
|
|
"2": {
|
|
"name": "punctuation.curly.brace.begin.mist"
|
|
}
|
|
},
|
|
"end": "\\}",
|
|
"endCaptures": {
|
|
"0": {
|
|
"name": "punctuation.curly.brace.end.mist"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{
|
|
"include": "#strings"
|
|
},
|
|
{
|
|
"include": "#numbers"
|
|
},
|
|
{
|
|
"include": "#keywords"
|
|
},
|
|
{
|
|
"include": "#lifetimes"
|
|
},
|
|
{
|
|
"include": "#types"
|
|
},
|
|
{
|
|
"include": "#operators"
|
|
},
|
|
{
|
|
"include": "#punctuation"
|
|
},
|
|
{
|
|
"include": "#field_access"
|
|
},
|
|
{
|
|
"match": "[a-zA-Z_][a-zA-Z0-9_]*\\s*(?=:)",
|
|
"name": "variable.object.field.mist"
|
|
},
|
|
{
|
|
"include": "$self"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"method_calls": {
|
|
"match": "\\.([a-zA-Z_][a-zA-Z0-9_]*)(?=\\s*(?:<[^;(){}]*>)?\\s*\\()",
|
|
"captures": {
|
|
"1": {
|
|
"name": "entity.name.function.mist"
|
|
}
|
|
}
|
|
},
|
|
"field_access": {
|
|
"match": "\\.([a-zA-Z_][a-zA-Z0-9_]*)\\b",
|
|
"captures": {
|
|
"1": {
|
|
"name": "variable.other.property.mist"
|
|
}
|
|
}
|
|
},
|
|
"path_continuation": {
|
|
"match": "::\\s*([a-zA-Z_][a-zA-Z0-9_]*+)(?!\\s*\\()",
|
|
"captures": {
|
|
"1": {
|
|
"name": "entity.name.namespace.mist"
|
|
}
|
|
}
|
|
},
|
|
"arrow": {
|
|
"match": "=>",
|
|
"name": "keyword.operator.arrow.mist"
|
|
},
|
|
"return_arrow": {
|
|
"match": "->",
|
|
"name": "keyword.operator.arrow.mist"
|
|
},
|
|
"functions": {
|
|
"match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)(?=\\s*(?:<[^;(){}]*>)?\\s*\\()",
|
|
"captures": {
|
|
"1": {
|
|
"name": "entity.name.function.mist"
|
|
}
|
|
}
|
|
},
|
|
"impl": {
|
|
"patterns": [
|
|
{
|
|
"match": "\\b(impl)\\s+([a-zA-Z_][a-zA-Z0-9_]*)\\s+for\\s+([a-zA-Z_][a-zA-Z0-9_]*)",
|
|
"captures": {
|
|
"1": {
|
|
"name": "storage.type.mist"
|
|
},
|
|
"2": {
|
|
"patterns": [
|
|
{
|
|
"include": "#types"
|
|
}
|
|
]
|
|
},
|
|
"3": {
|
|
"patterns": [
|
|
{
|
|
"include": "#types"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"match": "\\b(impl)\\s+([a-zA-Z_][a-zA-Z0-9_]*)\\s+",
|
|
"captures": {
|
|
"1": {
|
|
"name": "storage.type.mist"
|
|
},
|
|
"2": {
|
|
"patterns": [
|
|
{
|
|
"include": "#types"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"operators": {
|
|
"patterns": [
|
|
{
|
|
"match": "(?:\\+=|-=|\\*=|\\/=|%=|&=|\\|=|\\^=|<<=|>>=|<<|>>|\\.\\.=|\\.\\.|<=|>=|==|!=|&&|\\|\\||[+\\-*/%<>&|^=!]|\\+\\+|--|:)",
|
|
"name": "keyword.operator.mist"
|
|
}
|
|
]
|
|
},
|
|
"punctuation": {
|
|
"match": "::|:|;|,|\\.|\\{|\\}|\\(|\\)|\\[|\\]|\\?",
|
|
"name": "punctuation.mist"
|
|
},
|
|
"variables": {
|
|
"match": "\\b[a-zA-Z_][a-zA-Z0-9_]*\\b",
|
|
"name": "variable.other.mist"
|
|
}
|
|
}
|
|
} |