[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.
This commit is contained in:
parent
15fc6f25fd
commit
5d8f2c8526
@ -25,6 +25,7 @@ export function activate(context: ExtensionContext) {
|
||||
// Register the server for plain text documents
|
||||
documentSelector: [
|
||||
{ scheme: 'file', language: 'ligo' },
|
||||
{ scheme: 'file', language: 'mligo' },
|
||||
{ scheme: 'file', language: 'religo' }
|
||||
],
|
||||
synchronize: {
|
||||
|
@ -31,6 +31,12 @@
|
||||
"extensions": ["ligo"],
|
||||
"configuration": "./syntaxes/ligo.configuration.json"
|
||||
},
|
||||
{
|
||||
"id": "mligo",
|
||||
"aliases": ["CameLIGO"],
|
||||
"extensions": ["mligo"],
|
||||
"configuration": "./syntaxes/mligo.configuration.json"
|
||||
},
|
||||
{
|
||||
"id": "religo",
|
||||
"aliases": ["ReasonLIGO"],
|
||||
@ -44,6 +50,11 @@
|
||||
"scopeName": "source.ligo",
|
||||
"path": "./syntaxes/ligo.tmLanguage.json"
|
||||
},
|
||||
{
|
||||
"language": "mligo",
|
||||
"scopeName": "source.mligo",
|
||||
"path": "./syntaxes/mligo.tmLanguage.json"
|
||||
},
|
||||
{
|
||||
"language": "religo",
|
||||
"scopeName": "source.religo",
|
||||
|
@ -2,101 +2,194 @@
|
||||
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
|
||||
"name": "ligo",
|
||||
"patterns": [
|
||||
{ "include": "#controlkeywords" },
|
||||
{ "include": "#function" },
|
||||
{ "include": "#strings" },
|
||||
{ "include": "#string" },
|
||||
{ "include": "#single-quotes" },
|
||||
{ "include": "#comment" },
|
||||
{ "include": "#multilineComment" },
|
||||
{ "include": "#singlequotes" },
|
||||
{ "include": "#type" },
|
||||
{ "include": "#typeDeclaration" },
|
||||
{ "include": "#otherkeywords" },
|
||||
{ "include": "#variableInit" },
|
||||
{ "include": "#variableDeclaration" }
|
||||
{ "include": "#function" },
|
||||
{ "include": "#binding" },
|
||||
{ "include": "#type-annotation" },
|
||||
{ "include": "#type-definition" },
|
||||
{ "include": "#control-keywords" },
|
||||
{ "include": "#other-keywords" },
|
||||
{ "include": "#function-application" },
|
||||
{ "include": "#identifiers" }
|
||||
],
|
||||
"repository": {
|
||||
"controlkeywords": {
|
||||
"patterns": [{
|
||||
"name": "keyword.control.ligo",
|
||||
"match": "\\b(if|while|for|return|nil|remove|from|else|then|None|Some|True|False|Unit|skip)\\b"
|
||||
}]
|
||||
},
|
||||
"otherkeywords": {
|
||||
"patterns": [{
|
||||
"name": "keyword.other.ligo",
|
||||
"match": "\\b(case|with|is|function|var|const|type|end|begin|block|sender|source|amount|balance|now)\\b"
|
||||
}]
|
||||
},
|
||||
"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": [
|
||||
{
|
||||
"name": "entity.name.function.ligo",
|
||||
"match": "(?!with\\b)\\b\\w+ ?(?=\\()"
|
||||
"begin": "\\(",
|
||||
"end": "\\)",
|
||||
"patterns": [
|
||||
{ "include": "#comment" },
|
||||
{ "include": "#type-expression" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"match": "((?:(?!\\bis\\b|:=)[^=()|;}\\]])*)",
|
||||
"captures": {
|
||||
"1": { "name": "entity.name.type.ligo" }
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"strings": {
|
||||
|
||||
"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": [
|
||||
{
|
||||
"patterns": [{
|
||||
"name": "constant.character.escape.ligo",
|
||||
"match": "\\\\."
|
||||
}
|
||||
]
|
||||
}]
|
||||
},
|
||||
"singlequotes" : {
|
||||
|
||||
"single-quotes" : {
|
||||
"name": "string.quoted.single.ligo",
|
||||
"begin": "\\'",
|
||||
"end": "\\'",
|
||||
"patterns" : []
|
||||
},
|
||||
|
||||
|
||||
"comment": {
|
||||
"patterns": [
|
||||
{
|
||||
"name": "comment.line.double-slash.ligo",
|
||||
"match": "(//.*)"
|
||||
}
|
||||
]
|
||||
},
|
||||
"multilineComment" : {
|
||||
"name" : "comment.line.double-slash.ligo",
|
||||
"begin" : "\\(\\*",
|
||||
"end" : "\\*\\)",
|
||||
"patterns" : []
|
||||
},
|
||||
"type" : {
|
||||
"patterns" : [
|
||||
},
|
||||
{
|
||||
"name" : "support.type.ligo",
|
||||
"match": "\\b(bool|int|unit|string|nat|tez|map|timestamp|signature|key|big_map|list|set|record|address|option)\\b"
|
||||
"name" : "comment.line.double-slash.ligo",
|
||||
"begin" : "\\(\\*",
|
||||
"end" : "\\*\\)",
|
||||
"patterns" : []
|
||||
}
|
||||
]
|
||||
},
|
||||
"typeDeclaration" : {
|
||||
"patterns" : [
|
||||
{
|
||||
"name" : "support.type.ligo",
|
||||
"match": "\\w+ ?(?= is )"
|
||||
}
|
||||
]
|
||||
|
||||
"list-cons": {
|
||||
"match": "::",
|
||||
"name": "keyword.operator.cons.ligo"
|
||||
},
|
||||
"variableInit" : {
|
||||
"patterns" : [
|
||||
{
|
||||
"name" : "support.variable.ligo",
|
||||
"match": "\\w+ ?(?=\\:\\=)"
|
||||
}
|
||||
]
|
||||
|
||||
"control-keywords": {
|
||||
"name": "keyword.control.ligo",
|
||||
"match": "\\b(case|of|if|then|else|for|to|skip|assert|failwith)\\b"
|
||||
},
|
||||
"variableDeclaration" : {
|
||||
"patterns" : [
|
||||
{
|
||||
"name" : "support.variable.ligo",
|
||||
"match": "\\w+ ?(?=\\:)"
|
||||
}
|
||||
]
|
||||
|
||||
"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"
|
||||
|
25
tools/lsp/vscode-plugin/syntaxes/mligo.configuration.json
Normal file
25
tools/lsp/vscode-plugin/syntaxes/mligo.configuration.json
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"comments": {
|
||||
"lineComment": "//",
|
||||
"blockComment": [ "(*", "*)" ]
|
||||
},
|
||||
"brackets": [
|
||||
["{", "}"],
|
||||
["[", "]"],
|
||||
["(", ")"]
|
||||
],
|
||||
"autoClosingPairs": [
|
||||
["{", "}"],
|
||||
["[", "]"],
|
||||
["(", ")"],
|
||||
["\"", "\""],
|
||||
["'", "'"]
|
||||
],
|
||||
"surroundingPairs": [
|
||||
["{", "}"],
|
||||
["[", "]"],
|
||||
["(", ")"],
|
||||
["\"", "\""],
|
||||
["'", "'"]
|
||||
]
|
||||
}
|
252
tools/lsp/vscode-plugin/syntaxes/mligo.tmLanguage.json
Normal file
252
tools/lsp/vscode-plugin/syntaxes/mligo.tmLanguage.json
Normal file
@ -0,0 +1,252 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
|
||||
"name": "mligo",
|
||||
"patterns": [
|
||||
{ "include": "#string" },
|
||||
{ "include": "#single-quotes" },
|
||||
{ "include": "#comment" },
|
||||
{ "include": "#list-cons" },
|
||||
{ "include": "#let-binding" },
|
||||
{ "include": "#lambda" },
|
||||
{ "include": "#type-definition" },
|
||||
{ "include": "#type-annotation" },
|
||||
{ "include": "#control-keywords" },
|
||||
{ "include": "#other-keywords" },
|
||||
{ "include": "#numeric-literals" },
|
||||
{ "include": "#operators" },
|
||||
{ "include": "#function-application" },
|
||||
{ "include": "#identifiers" }
|
||||
],
|
||||
"repository": {
|
||||
"let-binding": {
|
||||
"begin": "\\b(let)\\b",
|
||||
"end": "(\\=)",
|
||||
"beginCaptures": {
|
||||
"1": { "name": "keyword.other.let-binding.mligo" }
|
||||
},
|
||||
"endCaptures": {
|
||||
"1": { "name": "keyword.operator.eq.mligo"}
|
||||
},
|
||||
"patterns": [
|
||||
{ "include": "#comment" },
|
||||
{ "include": "#let-rec" },
|
||||
{ "include": "#let-function" },
|
||||
{ "include": "#let-constant" }
|
||||
]
|
||||
},
|
||||
|
||||
"let-rec": {
|
||||
"match": "\\b(rec)\\b",
|
||||
"name": "keyword.other.recursive.mligo"
|
||||
},
|
||||
|
||||
"let-function": {
|
||||
"begin": "([a-zA-Z_]\\w*)?\\b(?=\\s*\\()",
|
||||
"beginCaptures": {
|
||||
"1": { "name": "entity.name.function.mligo" }
|
||||
},
|
||||
"end": "(?=\\=)",
|
||||
"patterns": [
|
||||
{ "include": "#comment" },
|
||||
{ "include": "#parenthesized-definition" },
|
||||
{ "include": "#type-annotation" }
|
||||
]
|
||||
},
|
||||
|
||||
"parenthesized-definition": {
|
||||
"begin": "\\(",
|
||||
"beginCaptures": {
|
||||
"1": { "name": "keyword.operator.parenthesis.mligo" }
|
||||
},
|
||||
"end": "\\)",
|
||||
"endCaptures": {
|
||||
"1": { "name": "keyword.operator.parenthesis.mligo" }
|
||||
},
|
||||
"patterns": [
|
||||
{ "include": "#comment" },
|
||||
{ "include": "#names-tuple" },
|
||||
{ "include": "#type-annotation" }
|
||||
]
|
||||
},
|
||||
|
||||
"names-tuple": {
|
||||
"begin": "(?<=\\()",
|
||||
"end": "(?=:)",
|
||||
"patterns": [
|
||||
{ "include": "#comment" },
|
||||
{ "include": "#names-tuple-name" }
|
||||
]
|
||||
},
|
||||
|
||||
"names-tuple-name": {
|
||||
"match": "(?:([a-zA-Z_]\\w*)(?=\\s*[,:]))+",
|
||||
"name": "support.variable.parameter.mligo"
|
||||
},
|
||||
|
||||
"type-annotation": {
|
||||
"begin": "(:)\\s*",
|
||||
"beginCaptures": {
|
||||
"1": { "name": "keyword.operator.type.mligo" }
|
||||
},
|
||||
"end": "(?:[;|]|(?=[)=}])|$)",
|
||||
"patterns": [
|
||||
{ "include": "#comment" },
|
||||
{ "include": "#type-expression" }
|
||||
]
|
||||
},
|
||||
|
||||
"type-expression": {
|
||||
"patterns": [
|
||||
{
|
||||
"begin": "\\(",
|
||||
"end": "\\)",
|
||||
"patterns": [
|
||||
{ "include": "#comment" },
|
||||
{ "include": "#type-expression" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"match": "([^=()|;}]*)",
|
||||
"captures": {
|
||||
"1": { "name": "entity.name.type.mligo" }
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
"let-constant": {
|
||||
"begin": "([a-zA-Z_]\\w*)\\b(?!\\s*\\()",
|
||||
"beginCaptures": {
|
||||
"1": { "name": "support.variable.mligo" }
|
||||
},
|
||||
"end": "(?=\\=)",
|
||||
"patterns": [
|
||||
{ "include": "#comment" },
|
||||
{ "include": "#type-annotation" }
|
||||
]
|
||||
},
|
||||
|
||||
"lambda": {
|
||||
"begin": "\\b(fun)\\b",
|
||||
"beginCaptures": {
|
||||
"1": { "name": "keyword.other.lambda.mligo" }
|
||||
},
|
||||
"end": "(->)",
|
||||
"endCaptures": {
|
||||
"1": { "name": "keyword.operator.lambda.mligo"}
|
||||
},
|
||||
"patterns": [
|
||||
{ "include": "#comment" },
|
||||
{ "include": "#parenthesized-definition" }
|
||||
]
|
||||
},
|
||||
|
||||
"type-definition": {
|
||||
"begin": "\\b(type)\\s+([a-zA-Z_]\\w*)\\b",
|
||||
"beginCaptures": {
|
||||
"1": { "name": "keyword.other.typedef.mligo" },
|
||||
"2": { "name": "entity.name.type.mligo" }
|
||||
},
|
||||
"end": "(?=(?:\\blet\\b|\\btype\\b))",
|
||||
"patterns": [
|
||||
{ "include": "#comment" },
|
||||
{ "include": "#struct-type" },
|
||||
{ "include": "#sum-type" }
|
||||
]
|
||||
},
|
||||
|
||||
"struct-type": {
|
||||
"begin": "\\{",
|
||||
"end": "\\}",
|
||||
"patterns": [
|
||||
{ "include": "#comment" },
|
||||
{ "include": "#names-tuple-name" },
|
||||
{ "include": "#type-annotation" }
|
||||
]
|
||||
},
|
||||
|
||||
"sum-type": {
|
||||
"begin": "\\b([a-zA-Z_]\\w*)\\s+(of)",
|
||||
"beginCaptures": {
|
||||
"1": { "name": "entity.name.function.mligo" },
|
||||
"2": { "name": "keyword.other.of.mligo" }
|
||||
},
|
||||
"end": "(\\||\\blet\\b|\\btype\\b)",
|
||||
"patterns": [
|
||||
{ "include": "#type-expression" }
|
||||
]
|
||||
},
|
||||
|
||||
"string": {
|
||||
"name": "string.quoted.double.mligo",
|
||||
"begin": "\"",
|
||||
"end": "\"",
|
||||
"patterns": [{
|
||||
"name": "constant.character.escape.mligo",
|
||||
"match": "\\\\."
|
||||
}]
|
||||
},
|
||||
"single-quotes" : {
|
||||
"name": "string.quoted.single.mligo",
|
||||
"begin": "\\'",
|
||||
"end": "\\'",
|
||||
"patterns" : []
|
||||
},
|
||||
|
||||
|
||||
"comment": {
|
||||
"patterns": [
|
||||
{
|
||||
"name": "comment.line.double-slash.mligo",
|
||||
"match": "(//.*)"
|
||||
},
|
||||
{
|
||||
"name" : "comment.line.double-slash.mligo",
|
||||
"begin" : "\\(\\*",
|
||||
"end" : "\\*\\)",
|
||||
"patterns" : []
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
"list-cons": {
|
||||
"match": "::",
|
||||
"name": "keyword.operator.cons.mligo"
|
||||
},
|
||||
|
||||
"control-keywords": {
|
||||
"name": "keyword.control.mligo",
|
||||
"match": "\\b(match|with|if|then|else|assert|failwith)\\b"
|
||||
},
|
||||
|
||||
"other-keywords": {
|
||||
"name": "keyword.other.mligo",
|
||||
"match": "\\b(in|begin|end)\\b"
|
||||
},
|
||||
|
||||
"numeric-literals": {
|
||||
"name": "constant.numeric.mligo",
|
||||
"match": "\\b\\d+"
|
||||
},
|
||||
|
||||
"operators": {
|
||||
"name": "keyword.operator.other.mligo",
|
||||
"match": "([-+*/])"
|
||||
},
|
||||
|
||||
"function-application": {
|
||||
"comment": "We need a negative lookahead here because instead of matching the first rule, TM picks the _longest match_. Without the lookahead, this rule conflicts with #let-binding and #control-keywords.",
|
||||
"match": "(?<=(?:match|with|if|then|else|assert|in|begin|failwith) |->|^|[|=\\.(])\\s*((?!(?:match|with|if|then|else|assert|in|begin|end|let|type|fun|failwith)\\b)[a-zA-Z_]\\w*)\\s+(?=(\\d|[\\[('\"]|[a-zA-Z_]\\w*))",
|
||||
"captures": {
|
||||
"1": { "name": "entity.name.function" }
|
||||
}
|
||||
},
|
||||
"identifiers": {
|
||||
"match": "\\b([a-zA-Z_]\\w*)\\b",
|
||||
"captures": {
|
||||
"1": { "name": "entity.name.variable" }
|
||||
}
|
||||
}
|
||||
},
|
||||
"scopeName": "source.mligo"
|
||||
}
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user