From beae1763202a031638082f669cf4ed6bf24eaa62 Mon Sep 17 00:00:00 2001 From: Andrew Hariri Date: Sat, 3 Feb 2024 13:37:03 -0800 Subject: [PATCH] [move] Move language support --- packages/tm-grammars/NOTICE | 12 + packages/tm-grammars/README.md | 5 +- packages/tm-grammars/grammars/glimmer-js.json | 2 +- packages/tm-grammars/grammars/glimmer-ts.json | 2 +- packages/tm-grammars/grammars/move.json | 1069 +++++++++++++++++ packages/tm-grammars/index.js | 27 +- samples/move.sample | 26 + sources-grammars.ts | 5 + 8 files changed, 1136 insertions(+), 12 deletions(-) create mode 100644 packages/tm-grammars/grammars/move.json create mode 100644 samples/move.sample diff --git a/packages/tm-grammars/NOTICE b/packages/tm-grammars/NOTICE index 5fca584..d4f1bd0 100644 --- a/packages/tm-grammars/NOTICE +++ b/packages/tm-grammars/NOTICE @@ -4271,6 +4271,18 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +========================================================================================================= +Files: move.json +License: https://raw.githubusercontent.com/damirka/move-syntax/main/LICENSE +SPDX: MIT +--------------------------------------------------------------------------------------------------------- +Copyright 2021 Damir Shamanaev + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ========================================================================================================= Files: narrat.json License: https://raw.githubusercontent.com/liana-p/narrat-syntax-highlighting-vscode/main/LICENSE diff --git a/packages/tm-grammars/README.md b/packages/tm-grammars/README.md index 23d77c9..b5b3827 100644 --- a/packages/tm-grammars/README.md +++ b/packages/tm-grammars/README.md @@ -75,8 +75,8 @@ import { grammars } from 'tm-grammars' | `gherkin` | | [alexkrechik/VSCucumberAutoComplete](https://github.com/alexkrechik/VSCucumberAutoComplete/blob/fc8da969b1c83e13ef5124b1ec90ba5211bc1e5f/gclient/syntaxes/feature.tmLanguage) | [MIT](https://raw.githubusercontent.com/alexkrechik/VSCucumberAutoComplete/master/LICENSE) | | 12.13 kB | | `git-commit` | | [microsoft/vscode](https://github.com/microsoft/vscode/blob/f8c3f89468fea14103d8790d59ea8594d6e644eb/extensions/git-base/syntaxes/git-commit.tmLanguage.json) | [MIT](https://raw.githubusercontent.com/microsoft/vscode/main/LICENSE.txt) | `diff` | 1.36 kB | | `git-rebase` | | [microsoft/vscode](https://github.com/microsoft/vscode/blob/e95c74c4c7af876e79ec58df262464467c06df28/extensions/git-base/syntaxes/git-rebase.tmLanguage.json) | [MIT](https://raw.githubusercontent.com/microsoft/vscode/main/LICENSE.txt) | `shellscript` | 818.00 B | -| `glimmer-js` | `gjs` | [lifeart/vsc-ember-syntax](https://github.com/lifeart/vsc-ember-syntax/blob/f031ed7df2eeced760f4469fc9fe06f8688c531a/syntaxes/source.gjs.json) | [MIT](https://raw.githubusercontent.com/lifeart/vsc-ember-syntax/master/LICENSE) | `javascript` `typescript` `css` `html` | 19.08 kB | -| `glimmer-ts` | `gts` | [lifeart/vsc-ember-syntax](https://github.com/lifeart/vsc-ember-syntax/blob/f031ed7df2eeced760f4469fc9fe06f8688c531a/syntaxes/source.gts.json) | [MIT](https://raw.githubusercontent.com/lifeart/vsc-ember-syntax/master/LICENSE) | `typescript` `css` `javascript` `html` | 19.08 kB | +| `glimmer-js` | `gjs` | [lifeart/vsc-ember-syntax](https://github.com/lifeart/vsc-ember-syntax/blob/312fb20cc04374eb8768369ebccabd12143edbe4/syntaxes/source.gjs.json) | [MIT](https://raw.githubusercontent.com/lifeart/vsc-ember-syntax/master/LICENSE) | `javascript` `typescript` `css` `html` | 19.08 kB | +| `glimmer-ts` | `gts` | [lifeart/vsc-ember-syntax](https://github.com/lifeart/vsc-ember-syntax/blob/312fb20cc04374eb8768369ebccabd12143edbe4/syntaxes/source.gts.json) | [MIT](https://raw.githubusercontent.com/lifeart/vsc-ember-syntax/master/LICENSE) | `typescript` `css` `javascript` `html` | 19.08 kB | | `glsl` | | [polym0rph/GLSL.tmbundle](https://github.com/polym0rph/GLSL.tmbundle/blob/6998d3bbd204e26746a5ca580cda4c650b9057b1/Syntaxes/GLSL.tmLanguage) | | `c` | 3.69 kB | | `gnuplot` | | [MarioSchwalbe/vscode-gnuplot](https://github.com/MarioSchwalbe/vscode-gnuplot/blob/c62c1a61c9b6b4658b43d76c397dc2ad43523b6a/syntaxes/gnuplot.tmLanguage) | [GPL-3.0](https://raw.githubusercontent.com/MarioSchwalbe/vscode-gnuplot/master/LICENSE) | | 16.46 kB | | `go` | | [microsoft/vscode](https://github.com/microsoft/vscode/blob/35d97bc7e439fce0f50f42074041ab2d8571b20a/extensions/go/syntaxes/go.tmLanguage.json) | [MIT](https://raw.githubusercontent.com/microsoft/vscode/main/LICENSE.txt) | | 41.19 kB | @@ -122,6 +122,7 @@ import { grammars } from 'tm-grammars' | `mdx` | | [wooorm/markdown-tm-language](https://github.com/wooorm/markdown-tm-language/blob/371d61df9ddc3850e12aabe61b602d02e259e8a4/source.mdx.tmLanguage) | [MIT](https://raw.githubusercontent.com/wooorm/markdown-tm-language/main/license) | `tsx` `toml` `yaml` `c` `clojure` `coffee` `cpp` `csharp` `css` `diff` `docker` `elixir` `elm` `erlang` `go` `graphql` `haskell` `html` `ini` `java` `javascript` `json` `julia` `kotlin` `less` `lua` `make` `markdown` `objective-c` `perl` `python` `r` `ruby` `rust` `scala` `scss` `shellscript` `shellsession` `sql` `xml` `swift` `typescript` | 120.76 kB | | `mermaid` | | [bpruitt-goddard/vscode-mermaid-syntax-highlight](https://github.com/bpruitt-goddard/vscode-mermaid-syntax-highlight/blob/8b62f487cb7a89afcd152febfbf47f5d4787657f/syntaxes/mermaid.tmLanguage.yaml) | [MIT](https://raw.githubusercontent.com/bpruitt-goddard/vscode-mermaid-syntax-highlight/master/LICENSE) | | 19.88 kB | | `mojo` | | [modularml/mojo-syntax](https://github.com/modularml/mojo-syntax/blob/a2241dda06d9a20503394c3affa606114d007049/syntaxes/mojo.syntax.json) | [MIT](https://raw.githubusercontent.com/modularml/mojo-syntax/main/LICENSE) | | 72.95 kB | +| `move` | | [damirka/move-syntax](https://github.com/damirka/move-syntax/blob/de9244e81505ff9154dc9422dbce434ac86fb981/syntaxes/move.tmLanguage.json) | [MIT](https://raw.githubusercontent.com/damirka/move-syntax/main/LICENSE) | | 13.82 kB | | `narrat` | `nar` | [liana-p/narrat-syntax-highlighting-vscode](https://github.com/liana-p/narrat-syntax-highlighting-vscode/blob/00d4b410338fc50ca0ce77a1f7e873c1fb66d376/syntaxes/narrat.tmLanguage.yaml) | [MIT](https://raw.githubusercontent.com/liana-p/narrat-syntax-highlighting-vscode/main/LICENSE) | | 3.41 kB | | `nextflow` | `nf` | [nextflow-io/vscode-language-nextflow](https://github.com/nextflow-io/vscode-language-nextflow/blob/7eeb9be8d01556b7c51c59307275c2f720f2ddf4/syntaxes/nextflow.tmLanguage.json) | [MIT](https://raw.githubusercontent.com/nextflow-io/vscode-language-nextflow/master/LICENSE.md) | | 4.40 kB | | `nginx` | | [hangxingliu/vscode-nginx-conf-hint](https://github.com/hangxingliu/vscode-nginx-conf-hint/blob/0582d5b71a31ff893b3587996b233f22239fba57/src/syntax/nginx.tmLanguage) | [GPL-3.0](https://raw.githubusercontent.com/hangxingliu/vscode-nginx-conf-hint/main/LICENSE) | `lua` | 32.83 kB | diff --git a/packages/tm-grammars/grammars/glimmer-js.json b/packages/tm-grammars/grammars/glimmer-js.json index d3801c3..70e4011 100644 --- a/packages/tm-grammars/grammars/glimmer-js.json +++ b/packages/tm-grammars/grammars/glimmer-js.json @@ -281,7 +281,7 @@ "match": "(::|_|\\$|\\.)" }, "glimmer-control-expression": { - "begin": "({{~?)(([-a-z/]+)\\s)", + "begin": "({{~?)(([-a-zA-Z_0-9/]+)\\s)", "captures": { "1": { "name": "keyword.operator" diff --git a/packages/tm-grammars/grammars/glimmer-ts.json b/packages/tm-grammars/grammars/glimmer-ts.json index 06a7b15..d4b862c 100644 --- a/packages/tm-grammars/grammars/glimmer-ts.json +++ b/packages/tm-grammars/grammars/glimmer-ts.json @@ -281,7 +281,7 @@ "match": "(::|_|\\$|\\.)" }, "glimmer-control-expression": { - "begin": "({{~?)(([-a-z/]+)\\s)", + "begin": "({{~?)(([-a-zA-Z_0-9/]+)\\s)", "captures": { "1": { "name": "keyword.operator" diff --git a/packages/tm-grammars/grammars/move.json b/packages/tm-grammars/grammars/move.json new file mode 100644 index 0000000..dd10e09 --- /dev/null +++ b/packages/tm-grammars/grammars/move.json @@ -0,0 +1,1069 @@ +{ + "displayName": "Move", + "name": "move", + "patterns": [ + { + "include": "#address" + }, + { + "include": "#comments" + }, + { + "include": "#module" + }, + { + "include": "#script" + }, + { + "include": "#macros" + } + ], + "repository": { + "address": { + "begin": "\\b(address)\\b", + "beginCaptures": { + "1": { + "name": "storage.modifier.type.address.keyword.move" + } + }, + "comment": "Address block", + "end": "(?<=})", + "name": "meta.address_block.move", + "patterns": [ + { + "include": "#comments" + }, + { + "begin": "(?<=address)", + "comment": "Address value/const", + "end": "(?=[{])", + "name": "meta.address.definition.move", + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#address_literal" + }, + { + "comment": "Named Address", + "match": "\\b(\\w+)\\b", + "name": "entity.name.type.move" + } + ] + }, + { + "include": "#module" + } + ] + }, + "address_literal": { + "patterns": [ + { + "comment": "16-byte (or shorter) hex address in Libra", + "match": "\\b(0x[A-Fa-f0-9][A-Fa-f0-9]{,31})\\b", + "name": "support.constant.diem.address.move" + }, + { + "comment": "Bech32 with wallet1 prefix - Dfinance format", + "match": "\\b(wallet1\\w{38})", + "name": "support.constant.dfinance.address.move" + }, + { + "comment": "Named address parameter (as build flag)", + "match": "\\s([@]\\w+)\\b", + "name": "support.constant.named.address.move" + } + ] + }, + "as": { + "comment": "Keyword as", + "match": "\\b(as)\\b", + "name": "keyword.control.move" + }, + "as-import": { + "comment": "Keyword as in import statement", + "match": "\\b(as)\\b", + "name": "meta.import_as.move" + }, + "assert": { + "comment": "Assert built-in", + "match": "\\b(assert)\\b", + "name": "support.function.assert.move" + }, + "block": { + "begin": "{", + "comment": "Block expression or definition", + "end": "}", + "name": "meta.block.move", + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#as" + }, + { + "include": "#mut" + }, + { + "include": "#let" + }, + { + "include": "#types" + }, + { + "include": "#assert" + }, + { + "include": "#literals" + }, + { + "include": "#control" + }, + { + "include": "#move_copy" + }, + { + "include": "#resource_methods" + }, + { + "include": "#module_access" + }, + { + "include": "#fun_call" + }, + { + "include": "#block" + } + ] + }, + "block-comments": { + "comment": "Supported since https://github.com/diem/diem/pull/3714", + "patterns": [ + { + "begin": "/\\*[\\*!](?![\\*/])", + "comment": "Block documentation comment", + "end": "\\*/", + "name": "comment.block.documentation.move" + }, + { + "begin": "/\\*", + "comment": "Block comment", + "end": "\\*/", + "name": "comment.block.move" + } + ] + }, + "comments": { + "name": "meta.comments.move", + "patterns": [ + { + "include": "#line-comments" + }, + { + "include": "#block-comments" + } + ] + }, + "const": { + "begin": "\\b(const)\\b", + "beginCaptures": { + "1": { + "name": "storage.modifier.const.move" + } + }, + "end": ";", + "name": "meta.const.move", + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#primitives" + }, + { + "include": "#vector" + }, + { + "include": "#literals" + }, + { + "match": "\\b([\\w_]+)\\b", + "name": "constant.other.move" + } + ] + }, + "control": { + "comment": "Control flow", + "match": "\\b(return|while|loop|if|else|break|continue|abort)\\b", + "name": "keyword.control.move" + }, + "entry_fun": { + "begin": "\\b(entry)\\b", + "beginCaptures": { + "1": { + "name": "storage.modifier.entry.move" + } + }, + "comment": "entry fun name() {}", + "end": "(?<=})", + "name": "meta.entry_fun.move", + "patterns": [ + { + "include": "#comments" + }, + { + "comment": "entry native function", + "match": "\\b(native)\\b", + "name": "storage.modifier.native.move" + }, + { + "comment": "entry public function", + "match": "\\b(public)\\b", + "name": "storage.modifier.public.move" + }, + { + "include": "#fun" + } + ] + }, + "friend": { + "begin": "\\b(friend)\\b", + "beginCaptures": { + "1": { + "name": "storage.modifier.type.move" + } + }, + "end": ";", + "name": "meta.friend.move", + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#address_literal" + }, + { + "comment": "Name of the imported module", + "match": "\\b(\\w+)\\b", + "name": "entity.name.type.module.move" + } + ] + }, + "fun": { + "patterns": [ + { + "include": "#fun_signature" + }, + { + "include": "#fun_body" + } + ] + }, + "fun_body": { + "begin": "{", + "comment": "Function body", + "end": "}", + "name": "meta.fun_body.move", + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#import" + }, + { + "include": "#as" + }, + { + "include": "#mut" + }, + { + "include": "#let" + }, + { + "include": "#types" + }, + { + "include": "#assert" + }, + { + "include": "#literals" + }, + { + "include": "#control" + }, + { + "include": "#move_copy" + }, + { + "include": "#resource_methods" + }, + { + "include": "#self_access" + }, + { + "include": "#module_access" + }, + { + "include": "#fun_call" + }, + { + "include": "#block" + } + ] + }, + "fun_call": { + "begin": "\\b(\\w+)\\s*(?:<[\\w\\s,]+>)?\\s*[(]", + "beginCaptures": { + "1": { + "name": "entity.name.function.call.move" + } + }, + "comment": "Function call", + "end": "[)]", + "name": "meta.fun_call.move", + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#resource_methods" + }, + { + "include": "#self_access" + }, + { + "include": "#module_access" + }, + { + "include": "#move_copy" + }, + { + "include": "#literals" + }, + { + "include": "#fun_call" + }, + { + "include": "#block" + }, + { + "include": "#mut" + }, + { + "include": "#as" + } + ] + }, + "fun_signature": { + "begin": "\\b(fun)\\b", + "beginCaptures": { + "1": { + "name": "storage.modifier.fun.move" + } + }, + "comment": "Function signature", + "end": "(?=[;{])", + "name": "meta.fun_signature.move", + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#module_access" + }, + { + "include": "#types" + }, + { + "include": "#mut" + }, + { + "begin": "(?<=fun)", + "comment": "Function name", + "end": "(?=[<(])", + "name": "meta.function_name.move", + "patterns": [ + { + "include": "#comments" + }, + { + "match": "\\b(\\w+)\\b", + "name": "entity.name.function.move" + } + ] + }, + { + "include": "#type_param" + }, + { + "begin": "[(]", + "comment": "Parentheses", + "end": "[)]", + "name": "meta.parentheses.move", + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#self_access" + }, + { + "include": "#module_access" + }, + { + "include": "#types" + }, + { + "include": "#mut" + } + ] + }, + { + "comment": "Keyword acquires", + "match": "\\b(acquires)\\b", + "name": "storage.modifier" + } + ] + }, + "import": { + "begin": "\\b(use)\\b", + "beginCaptures": { + "1": { + "name": "storage.modifier.type.move" + } + }, + "end": ";", + "name": "meta.import.move", + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#address_literal" + }, + { + "include": "#as-import" + }, + { + "comment": "Uppercase entities", + "match": "\\b([A-Z]\\w*)\\b", + "name": "entity.name.type.move" + }, + { + "begin": "{", + "comment": "Module members", + "end": "}", + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#as-import" + }, + { + "comment": "Uppercase entities", + "match": "\\b([A-Z]\\w*)\\b", + "name": "entity.name.type.move" + } + ] + }, + { + "comment": "Name of the imported module", + "match": "\\b(\\w+)\\b", + "name": "meta.entity.name.type.module.move" + } + ] + }, + "let": { + "comment": "Keyword let", + "match": "\\b(let)\\b", + "name": "keyword.control.move" + }, + "line-comments": { + "begin": "//", + "comment": "Single-line comment", + "end": "$", + "name": "comment.line.double-slash.move" + }, + "literals": { + "patterns": [ + { + "comment": "Hex literal (still to find out)", + "match": "0x[_a-fA-F0-9]+(?:[iu](?:8|16|32|64|size))?", + "name": "constant.numeric.hex.move" + }, + { + "comment": "Numeric literal", + "match": "(? as hex literal: x", + "match": "x\"([A-F0-9a-f]+)\"", + "name": "meta.hex_literal.move" + }, + { + "comment": "Booleans", + "match": "\\b(?:true|false)\\b", + "name": "constant.language.boolean.move" + }, + { + "include": "#address_literal" + } + ] + }, + "macros": { + "match": "#\\[(?:[\\w0-9=,_\\(\\)\\s\"\\:=]+)\\]", + "name": "support.constant.macro.move" + }, + "module": { + "begin": "\\b(module|spec)\\b", + "beginCaptures": { + "1": { + "name": "storage.modifier.type.move" + } + }, + "comment": "Module definition", + "end": "(?<=})", + "name": "meta.module.move", + "patterns": [ + { + "include": "#comments" + }, + { + "begin": "(?<=(module|spec))", + "comment": "Module name", + "end": "(?={)", + "patterns": [ + { + "include": "#comments" + }, + { + "begin": "(?<=(module|spec))", + "comment": "Module namespace / address", + "end": "(?=[(::){])", + "name": "constant.other.move" + }, + { + "begin": "(?<=::)", + "comment": "Module name", + "end": "(?=[\\s{])", + "name": "entity.name.type.move" + } + ] + }, + { + "begin": "{", + "comment": "Module scope", + "end": "}", + "name": "meta.module_scope.move", + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#macros" + }, + { + "include": "#import" + }, + { + "include": "#friend" + }, + { + "include": "#const" + }, + { + "include": "#struct" + }, + { + "include": "#entry_fun" + }, + { + "include": "#native_fun" + }, + { + "include": "#public_fun" + }, + { + "include": "#fun" + }, + { + "include": "#spec" + }, + { + "include": "#block" + } + ] + } + ] + }, + "module_access": { + "captures": { + "1": { + "name": "meta.entity.name.type.accessed.module.move" + }, + "2": { + "name": "entity.name.function.call.move" + } + }, + "comment": "Use of module type or method", + "match": "\\b(\\w+)::(\\w+)\\b", + "name": "meta.module_access.move" + }, + "move_copy": { + "comment": "Keywords move and copy", + "match": "\\b(move|copy)\\b", + "name": "variable.language.move" + }, + "mut": { + "comment": "&mut reference", + "match": "(?<=&)(mut)\\b", + "name": "storage.modifier.mut.move" + }, + "native_fun": { + "begin": "\\b(native)\\b", + "beginCaptures": { + "1": { + "name": "storage.modifier.native.move" + } + }, + "comment": "Native function", + "end": "(?<=[;}])", + "name": "meta.native_fun.move", + "patterns": [ + { + "include": "#comments" + }, + { + "comment": "native public function", + "match": "\\b(public)\\b", + "name": "storage.modifier.public.move" + }, + { + "comment": "native entry function", + "match": "\\b(entry)\\b", + "name": "storage.modifier.entry.move" + }, + { + "include": "#fun_signature" + } + ] + }, + "phantom": { + "comment": "Keyword phantom inside type parameters", + "match": "\\b(phantom)\\b", + "name": "keyword.control.phantom.move" + }, + "primitives": { + "comment": "Primitive types", + "match": "\\b(u8|u16|u32|u64|u128|u256|address|bool|signer)\\b", + "name": "support.type.primitives.move" + }, + "public_fun": { + "begin": "\\b(public)\\b", + "beginCaptures": { + "1": { + "name": "storage.modifier.public.move" + } + }, + "comment": "Public function", + "end": "(?<=[;}])", + "name": "meta.public_fun.move", + "patterns": [ + { + "include": "#comments" + }, + { + "comment": "Public native function", + "match": "\\b(native)\\b", + "name": "storage.modifier.native.move" + }, + { + "comment": "Public entry function", + "match": "\\b(entry)\\b", + "name": "storage.modifier.entry.move" + }, + { + "begin": "\\(", + "comment": "Script visibility", + "end": "\\)", + "patterns": [ + { + "include": "#comments" + }, + { + "comment": "Friend or Script visibility", + "match": "\\b(script|friend)\\b", + "name": "storage.modifier.public.script.move" + } + ] + }, + { + "include": "#fun" + } + ] + }, + "resource_methods": { + "comment": "Methods to work with resource", + "match": "\\b(borrow_global|borrow_global_mut|exists|move_from|move_to_sender|move_to)\\b", + "name": "support.function.typed.move" + }, + "script": { + "begin": "\\b(script)\\b", + "beginCaptures": { + "1": { + "name": "storage.modifier.script.move" + } + }, + "end": "(?<=})", + "name": "meta.script.move", + "patterns": [ + { + "include": "#comments" + }, + { + "begin": "{", + "comment": "Script scope", + "end": "}", + "name": "meta.script_scope.move", + "patterns": [ + { + "include": "#const" + }, + { + "include": "#comments" + }, + { + "include": "#import" + }, + { + "include": "#fun" + } + ] + } + ] + }, + "self_access": { + "captures": { + "1": { + "name": "variable.language.self.move" + }, + "2": { + "name": "entity.name.function.call.move" + } + }, + "comment": "Use of Self", + "match": "\\b(Self)::(\\w+)\\b", + "name": "meta.self_access.move" + }, + "spec": { + "begin": "\\b(spec)\\b", + "beginCaptures": { + "1": { + "name": "storage.modifier.spec.move" + } + }, + "end": "(?<=[;}])", + "name": "meta.spec.move", + "patterns": [ + { + "comment": "Spec target", + "match": "\\b(module|schema|struct|fun)", + "name": "storage.modifier.spec.target.move" + }, + { + "comment": "Spec define inline", + "match": "\\b(define)", + "name": "storage.modifier.spec.define.move" + }, + { + "comment": "Target name", + "match": "\\b(\\w+)\\b", + "name": "entity.name.function.move" + }, + { + "begin": "{", + "comment": "Spec block", + "end": "}", + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#spec_block" + }, + { + "include": "#spec_types" + }, + { + "include": "#spec_define" + }, + { + "include": "#spec_keywords" + }, + { + "include": "#control" + }, + { + "include": "#fun_call" + }, + { + "include": "#literals" + }, + { + "include": "#types" + }, + { + "include": "#let" + } + ] + } + ] + }, + "spec_block": { + "begin": "{", + "comment": "Spec block", + "end": "}", + "name": "meta.spec_block.move", + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#spec_block" + }, + { + "include": "#spec_types" + }, + { + "include": "#fun_call" + }, + { + "include": "#literals" + }, + { + "include": "#control" + }, + { + "include": "#types" + }, + { + "include": "#let" + } + ] + }, + "spec_define": { + "begin": "\\b(define)\\b", + "beginCaptures": { + "1": { + "name": "keyword.control.move.spec" + } + }, + "comment": "Spec define keyword", + "end": "(?=[;{])", + "name": "meta.spec_define.move", + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#spec_types" + }, + { + "include": "#types" + }, + { + "begin": "(?<=define)", + "comment": "Function name", + "end": "(?=[(])", + "patterns": [ + { + "include": "#comments" + }, + { + "match": "\\b(\\w+)\\b", + "name": "entity.name.function.move" + } + ] + } + ] + }, + "spec_keywords": { + "match": "\\b(global|pack|unpack|pragma|native|include|ensures|requires|invariant|apply|aborts_if|modifies)\\b", + "name": "keyword.control.move.spec" + }, + "spec_types": { + "comment": "Spec-only types", + "match": "\\b(range|num|vector|bool|u8|u16|u32|u64|u128|u256|address)\\b", + "name": "support.type.vector.move" + }, + "struct": { + "begin": "\\b(struct)\\b", + "beginCaptures": { + "1": { + "name": "storage.modifier.type.move" + } + }, + "end": "(?<=})", + "name": "meta.struct.move", + "patterns": [ + { + "include": "#comments" + }, + { + "begin": "(?<=struct)", + "comment": "Struct definition", + "end": "(?={)", + "name": "meta.struct_def.move", + "patterns": [ + { + "include": "#comments" + }, + { + "comment": "Has Abilities", + "match": "\\b(has)\\b", + "name": "keyword.control.ability.has.move" + }, + { + "comment": "Ability", + "match": "\\b(store|key|drop|copy)\\b", + "name": "entity.name.type.ability.move" + }, + { + "comment": "Struct name", + "match": "\\b(\\w+)\\b", + "name": "entity.name.type.move" + }, + { + "include": "#type_param" + } + ] + }, + { + "begin": "{", + "comment": "Struct body", + "end": "}", + "name": "meta.struct_body.move", + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#self_access" + }, + { + "include": "#module_access" + }, + { + "include": "#types" + } + ] + } + ] + }, + "type_param": { + "begin": "<", + "comment": "Generic type param", + "end": ">", + "name": "meta.generic_param.move", + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#phantom" + }, + { + "include": "#module_access" + }, + { + "comment": "Trait-like condition", + "match": "\\b(store|drop|key|copy)\\b", + "name": "entity.name.type.kind.move" + } + ] + }, + "types": { + "comment": "Built-in types + vector", + "name": "meta.types.move", + "patterns": [ + { + "include": "#primitives" + }, + { + "include": "#vector" + }, + { + "comment": "Capitalized type names", + "match": "\\b([A-Z][A-Za-z_]+)\\b", + "name": "entity.name.type" + }, + { + "comment": "All-uppercase const literal", + "match": "\\b([A-Z_]+)\\b", + "name": "constant.other.move" + } + ] + }, + "vector": { + "begin": "\\b(vector)<", + "beginCaptures": { + "1": { + "name": "support.type.vector.move" + } + }, + "end": ">", + "name": "meta.vector.move", + "patterns": [ + { + "include": "#primitives" + }, + { + "include": "#vector" + } + ] + } + }, + "scopeName": "source.move" +} diff --git a/packages/tm-grammars/index.js b/packages/tm-grammars/index.js index 8018d5c..217d918 100644 --- a/packages/tm-grammars/index.js +++ b/packages/tm-grammars/index.js @@ -810,7 +810,7 @@ export const grammars = [ aliases: [ 'gjs', ], - byteSize: 19536, + byteSize: 19543, displayName: 'Glimmer JS', embedded: [ 'javascript', @@ -818,19 +818,19 @@ export const grammars = [ 'css', 'html', ], - lastUpdate: '2024-01-18T05:06:13Z', + lastUpdate: '2024-02-03T14:28:03Z', license: 'MIT', licenseUrl: 'https://raw.githubusercontent.com/lifeart/vsc-ember-syntax/master/LICENSE', name: 'glimmer-js', scopeName: 'source.gjs', - sha: 'f031ed7df2eeced760f4469fc9fe06f8688c531a', - source: 'https://github.com/lifeart/vsc-ember-syntax/blob/f031ed7df2eeced760f4469fc9fe06f8688c531a/syntaxes/source.gjs.json', + sha: '312fb20cc04374eb8768369ebccabd12143edbe4', + source: 'https://github.com/lifeart/vsc-ember-syntax/blob/312fb20cc04374eb8768369ebccabd12143edbe4/syntaxes/source.gjs.json', }, { aliases: [ 'gts', ], - byteSize: 19536, + byteSize: 19543, displayName: 'Glimmer TS', embedded: [ 'typescript', @@ -838,13 +838,13 @@ export const grammars = [ 'javascript', 'html', ], - lastUpdate: '2024-01-18T05:06:13Z', + lastUpdate: '2024-02-03T14:28:03Z', license: 'MIT', licenseUrl: 'https://raw.githubusercontent.com/lifeart/vsc-ember-syntax/master/LICENSE', name: 'glimmer-ts', scopeName: 'source.gts', - sha: 'f031ed7df2eeced760f4469fc9fe06f8688c531a', - source: 'https://github.com/lifeart/vsc-ember-syntax/blob/f031ed7df2eeced760f4469fc9fe06f8688c531a/syntaxes/source.gts.json', + sha: '312fb20cc04374eb8768369ebccabd12143edbe4', + source: 'https://github.com/lifeart/vsc-ember-syntax/blob/312fb20cc04374eb8768369ebccabd12143edbe4/syntaxes/source.gts.json', }, { byteSize: 3774, @@ -1674,6 +1674,17 @@ export const grammars = [ sha: 'a2241dda06d9a20503394c3affa606114d007049', source: 'https://github.com/modularml/mojo-syntax/blob/a2241dda06d9a20503394c3affa606114d007049/syntaxes/mojo.syntax.json', }, + { + byteSize: 14150, + displayName: 'Move', + lastUpdate: '2023-05-22T07:53:33Z', + license: 'MIT', + licenseUrl: 'https://raw.githubusercontent.com/damirka/move-syntax/main/LICENSE', + name: 'move', + scopeName: 'source.move', + sha: 'de9244e81505ff9154dc9422dbce434ac86fb981', + source: 'https://github.com/damirka/move-syntax/blob/de9244e81505ff9154dc9422dbce434ac86fb981/syntaxes/move.tmLanguage.json', + }, { aliases: [ 'nar', diff --git a/samples/move.sample b/samples/move.sample new file mode 100644 index 0000000..049e970 --- /dev/null +++ b/samples/move.sample @@ -0,0 +1,26 @@ +module 0xCAFE::BasicCoin { + // Only included in compilation for testing. Similar to #[cfg(testing)] + // in Rust. Imports the `Signer` module from the MoveStdlib package. + #[test_only] + use std::signer; + + struct Coin has key { + value: u64, + } + + public fun mint(account: signer, value: u64) { + move_to(&account, Coin { value }) + } + + // Declare a unit test. It takes a signer called `account` with an + // address value of `0xC0FFEE`. + #[test(account = @0xC0FFEE)] + fun test_mint_10(account: signer) acquires Coin { + let addr = signer::address_of(&account); + mint(account, 10); + // Make sure there is a `Coin` resource under `addr` with a value of `10`. + // We can access this resource and its value since we are in the + // same module that defined the `Coin` resource. + assert!(borrow_global(addr).value == 10, 0); + } +} \ No newline at end of file diff --git a/sources-grammars.ts b/sources-grammars.ts index b81e33c..88616e6 100644 --- a/sources-grammars.ts +++ b/sources-grammars.ts @@ -648,6 +648,11 @@ export const sourcesCommunity: GrammarSource[] = [ displayName: 'Mojo', source: 'https://github.com/modularml/mojo-syntax/blob/main/syntaxes/mojo.syntax.json', }, + { + name: 'move', + displayName: 'Move', + source: 'https://github.com/damirka/move-syntax/blob/main/syntaxes/move.tmLanguage.json', + }, { name: 'narrat', aliases: ['nar'],