ligo/tools/lsp/vscode-plugin/syntaxes/ligo.tmLanguage.json
Kirill Kuvshinov 5d8f2c8526
[LIGO-13] Add CameLIGO and ReasonLIGO
Problem: The previous version of the extension only supported
PascaLIGO dialect. We need to add syntax highlighting and
activation events for ReasonLIGO and CameLIGO.

Solution: Add .tmlanguage.json files for ReasonLIGO and CameLIGO,
add activation events.
2020-09-08 13:14:51 +03:00

197 lines
5.9 KiB
JSON

{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"name": "ligo",
"patterns": [
{ "include": "#string" },
{ "include": "#single-quotes" },
{ "include": "#comment" },
{ "include": "#function" },
{ "include": "#binding" },
{ "include": "#type-annotation" },
{ "include": "#type-definition" },
{ "include": "#control-keywords" },
{ "include": "#other-keywords" },
{ "include": "#function-application" },
{ "include": "#identifiers" }
],
"repository": {
"function": {
"begin": "\\b(recursive\\s+)?(function)\\s+([a-zA-Z_]\\w*)\\b",
"beginCaptures": {
"1": { "name": "keyword.other.recursive.ligo" },
"2": { "name": "keyword.other.function.ligo" },
"3": { "name": "entity.name.function" }
},
"end": "\\b(is)\\b",
"endCaptures": {
"1": { "name": "keyword.other.is.ligo"}
},
"patterns": [
{ "include": "#comment" },
{ "include": "#type-annotation" },
{ "include": "#binding" }
]
},
"binding": {
"begin": "\\b(var|const)\\s+([a-zA-Z_]\\w*)\\b",
"end": "([=),;]|:=)",
"beginCaptures": {
"1": { "name": "keyword.other.binding.ligo" },
"2": { "name": "entity.name.variable"}
},
"endCaptures": {
"1": { "name": "keyword.operator.eq.ligo"}
},
"patterns": [
{ "include": "#comment" },
{ "include": "#type-annotation" }
]
},
"type-annotation": {
"begin": "(:)\\s*",
"beginCaptures": {
"1": { "name": "keyword.operator.type.ligo" }
},
"end": "(?:\\||(?=[;)=}\\]]|\\bis\\b|:=)|$)",
"patterns": [
{ "include": "#comment" },
{ "include": "#type-expression" }
]
},
"type-expression": {
"patterns": [
{
"begin": "\\(",
"end": "\\)",
"patterns": [
{ "include": "#comment" },
{ "include": "#type-expression" }
]
},
{
"match": "((?:(?!\\bis\\b|:=)[^=()|;}\\]])*)",
"captures": {
"1": { "name": "entity.name.type.ligo" }
}
}
]
},
"type-definition": {
"begin": "\\b(type)\\s+([a-zA-Z_]\\w*)\\s+(is)\\b",
"beginCaptures": {
"1": { "name": "keyword.other.typedef.ligo" },
"2": { "name": "entity.name.type.ligo" },
"3": { "name": "keyword.other.is.ligo" }
},
"end": "(?=\\b(?:function|type||const|var)\\b)",
"patterns": [
{ "include": "#comment" },
{ "include": "#struct-type" },
{ "include": "#sum-type" }
]
},
"struct-type": {
"begin": "\\b(record)\\s*\\[",
"beginCaptures": {
"1": { "name": "keyword.other.record.ligo" }
},
"end": "\\]",
"patterns": [
{ "include": "#comment" },
{ "include": "#identifiers" },
{ "include": "#type-annotation" }
]
},
"sum-type": {
"begin": "\\b([a-zA-Z_]\\w*)\\s+(of)",
"beginCaptures": {
"1": { "name": "entity.name.function.ligo" },
"2": { "name": "keyword.other.of.ligo" }
},
"end": "(\\||\\blet\\b|\\btype\\b)",
"patterns": [
{ "include": "#type-expression" }
]
},
"string": {
"name": "string.quoted.double.ligo",
"begin": "\"",
"end": "\"",
"patterns": [{
"name": "constant.character.escape.ligo",
"match": "\\\\."
}]
},
"single-quotes" : {
"name": "string.quoted.single.ligo",
"begin": "\\'",
"end": "\\'",
"patterns" : []
},
"comment": {
"patterns": [
{
"name": "comment.line.double-slash.ligo",
"match": "(//.*)"
},
{
"name" : "comment.line.double-slash.ligo",
"begin" : "\\(\\*",
"end" : "\\*\\)",
"patterns" : []
}
]
},
"list-cons": {
"match": "::",
"name": "keyword.operator.cons.ligo"
},
"control-keywords": {
"name": "keyword.control.ligo",
"match": "\\b(case|of|if|then|else|for|to|skip|assert|failwith)\\b"
},
"other-keywords": {
"name": "keyword.other.ligo",
"match": "\\b(block|with|begin|end|record)\\b"
},
"numeric-literals": {
"name": "constant.numeric.ligo",
"match": "\\b\\d+"
},
"operators": {
"name": "keyword.operator.other.ligo",
"match": "([-+*/])"
},
"function-application": {
"match": "\\b([a-zA-Z_]\\w*)\\s+\\(",
"captures": {
"1": { "name": "entity.name.function" }
}
},
"identifiers": {
"match": "\\b([a-zA-Z_]\\w*)\\b",
"captures": {
"1": { "name": "entity.name.variable" }
}
}
},
"scopeName": "source.ligo"
}