├── .github └── workflows │ └── main.yml ├── .gitignore ├── .npmignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── extension.js ├── img ├── logo.256.png ├── sample_dark.png └── sample_light.png ├── language-configuration.json ├── package-lock.json ├── package.json ├── sample ├── 2024.move ├── 2024_struct.move ├── broken_sample.move └── label_module_suffix.move └── syntaxes ├── move-markdown-injection.json ├── move-mdx-injection.json └── move.tmLanguage.json /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | tags: 4 | - v* 5 | jobs: 6 | release: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - name: Get the version 10 | id: get_version 11 | run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} 12 | - uses: actions/checkout@v2 13 | - run: git fetch --depth=1 origin +refs/tags/${{ steps.get_version.outputs.VERSION }}:refs/tags/${{ steps.get_version.outputs.VERSION }} 14 | - run: git for-each-ref --format="## %(subject) %0a%0a %(body)" refs/tags/${{ steps.get_version.outputs.VERSION }} > body.md 15 | - uses: ncipollo/release-action@v1.6.1 16 | with: 17 | bodyFile: "body.md" 18 | token: ${{ secrets.GITHUB_TOKEN }} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | *.vsix 3 | node_modules 4 | .DS_Store 5 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | img 2 | node_modules 3 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | Version history from v0.1.0 to this day. 4 | 5 | ## v0.7.1 - Fix: constants allow digits 6 | 7 | - Fixes issue with constants not allowing digits 8 | 9 | ```move 10 | const MY_CONST_100: u8 = 1; 11 | const EMyError100: u64 = 2; 12 | ``` 13 | 14 | ## v0.7.0 - Better enums 15 | 16 | - Adds proper, Rust-like support for enums 17 | 18 | ```move 19 | public enum MyEnum { 20 | First, 21 | MyVariant(u8), 22 | AnotherVariant(u8, u8), 23 | YetAnotherVariant { a: u8, b: u8 }, 24 | } 25 | ``` 26 | 27 | ## v0.6.6 - Minor patch 28 | 29 | Fixes incorrect syntax in case of `_module` suffixed module name in module label. 30 | 31 | ```move 32 | module example_module::test_module; 33 | 34 | public fun say_hello() {} 35 | ``` 36 | 37 | ## v0.6.5 - Adds support for `match` expression 38 | 39 | - Adds support for `match` expression 40 | 41 | ```move 42 | module example::test_enum { 43 | public enum Sound { 44 | Beep, 45 | Boop, 46 | } 47 | 48 | public fun play_sound(sound: Sound) { 49 | match sound { 50 | Sound::Beep => {} 51 | Sound::Boop => {} 52 | } 53 | } 54 | } 55 | ``` 56 | 57 | ## v0.6.4 - Adds support for module labels 58 | 59 | - Adds support for module labels `module ::;` 60 | - Minor qol improvements 61 | 62 | ```move 63 | module book::example; 64 | 65 | public fun say_hello() {} 66 | ``` 67 | 68 | ## v0.6.3 - Literal support in annotations 69 | 70 | - Adds support for literals in annotations `#[test = 1]` 71 | - Allows any module member to exist outside of the module block 72 | 73 | ## v0.6.2 - Broken character escapes 74 | 75 | - Fixes bytestring special character escapes `b"\\"` 76 | - Adds underline for \`-escaped members in doc comments 77 | 78 | ## v0.6.1 - Positional structs! 79 | 80 | - Adds support for positional structs 81 | - Fixes issue with abilities defined before struct fields in positionals 82 | - Adds support for positional structs without abilities 83 | - Fixes issue with function name ending with `_fun` breaking the syntax highlighting 84 | - Same applies for a named address ending with `_module` in the module declaration 85 | 86 | ## v0.6.0 - Extended Support for Move 2024 87 | 88 | - Adds support for `macro!` calls in function blocks 89 | - Better highlighting in generics and type parameters 90 | - Supports `macro` keyword 91 | - Adds `public(package)` 92 | - New struct syntax 93 | - Support for `enum` 94 | - `use fun` aliases are now supported 95 | 96 | ## v0.5.0 - Move 2024 Edition support 97 | 98 | - Loosens visibility modifiers to allow for `public` struct 99 | - Adds support for backtick escaped identifiers 100 | - Generalized `mut` to a keyword that can be used in any position 101 | - Adds support for `mut` in function signatures 102 | - Receiver syntax aliases via `use fun` are now supported 103 | 104 | ## v0.4.15 - Simplified Markdown support in VSCode 105 | 106 | - Module is no longer a top-level requirement, codeblocks now support expressions and state 107 | 108 | ## v0.4.14 - Adds MDX support in VSCode 109 | 110 | - Adds support for "move" in codeblocks in VSCode (given that MDX extension is installed) 111 | 112 | ## v0.4.13 - Adds Markdown support in VSCode 113 | 114 | - Adds support for "move" in markdown codeblocks in VSCode 115 | 116 | ## v0.4.12 - Small patch in Macros 117 | 118 | - Highlights "`,`" comma separator in macros. 119 | 120 | ```move 121 | module example::test { 122 | #[test, expected_failure(abort_code = sui::kiosk::ENotOwner)] 123 | fun test_borrow() { 124 | // ... 125 | } 126 | } 127 | ``` 128 | 129 | ## v0.4.11 - GitHub Web-editor support 130 | 131 | - Adds "browser" configuration to `package.json` to enable extension in the browser 132 | - Fixes issue with macros - extends a set of symbols in the macro to hl expected_failure 133 | ```move 134 | module example::test { 135 | #[test] 136 | #[expected_failure(abort_code = 0)] 137 | fun test() { 138 | abort 0 139 | } 140 | } 141 | ``` 142 | 143 | ## v0.4.10 - Macros patches 144 | 145 | - Colon `:` used to break macro highlighting 146 | 147 | ```move 148 | module example::test { 149 | #[test] 150 | #[expected_failure(abort_code = sui::kiosk::ENotOwner)] 151 | fun test_borrow_fail_not_owner() {} 152 | } 153 | ``` 154 | 155 | ## v0.4.9 - Minor patches 156 | 157 | - Fixes language configuration for brackets and removes angles from the setting 158 | - Adds typed literal hl for `1u256`, `100u16` and `300u32` 159 | 160 | ## v0.4.8 - Better support for character escapes 161 | 162 | - Now escaped characters are highlighted correctly 163 | - ASCII literal no longer consumes all line 164 | 165 | ## v0.4.7 - New integer types 166 | 167 | - Adds support for u16, u32 and u256 168 | 169 | ## v0.4.6 - Removes highlights of imports 170 | 171 | - Lessens the amount of hl in `use` statement 172 | 173 | ## v0.4.5 - Adds back support for address block 174 | 175 | - adds back `address {}` block 176 | 177 | ## v0.4.4 - Minor impromevents 178 | 179 | - finally fixed the bug with 'public native' functions 180 | 181 | ## v0.4.3 - Minor improvements 182 | 183 | - allows highlighting `public(friend) native entry fun name();` 184 | - extends macros, allowing any text inside 185 | 186 | ## v0.4.2 - Entry functions 187 | 188 | - adds `entry` functions 189 | - allows import statement inside function body 190 | - fixes the issue with `native public` 191 | 192 | ## v0.4.1 - Minor bug fixes 193 | 194 | Fixes highlighting for: 195 | 196 | - public native functions (native keyword) 197 | - mutable references in function return values: &mut 198 | 199 | ## v0.4.0 - Sui + HL improvements 200 | 201 | - allow #[test] and #[test_only] macros on functions and modules 202 | - add module namespaces highlights 203 | - allow "public native" function hl as well as "native public" 204 | - improve struct type hl in function signatures and structs 205 | - highlight all-uppercase symbols as consts (e.g. MY_CUSTOM_CONST) 206 | 207 | ## v0.3.0 - Phantom type parameters 208 | 209 | - follow Move 1.4 changes, add phantom keyword 210 | - adds support for named addresses 211 | - legacy mentiones of Libra are changed to Diem 212 | 213 | ## v0.2.0 - Visible Friends with Abilities 214 | 215 | - `friend ;` statement support added 216 | - `public(friend)` and `public(script)` visibilities added 217 | - no more resources, only abilities, this also affects generic constraints: 218 | 219 | Examples: 220 | 221 | ```move 222 | use 0x1::A; 223 | friend A; 224 | struct Token has store, key, copy, drop { /* ... */ } 225 | public(friend) fun do { /* ... */ } 226 | ``` 227 | 228 | ## v0.1.0 - Move IDE separated into 2 different projects - syntax and IDE features 229 | 230 | - vscode-mode-ide is now vscode-move-syntax 231 | - recent language features added 232 | - all previous syntaxes left as is 233 | - mvir support removed 234 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2021 Damir Shamanaev 2 | 3 | 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: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | 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. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Move Language Syntax package 2 | 3 | This VSCode extension adds Move syntax support to VSCode (see [VSCode marketplace page](https://marketplace.visualstudio.com/items?itemName=damirka.move-syntax)). As well as defines the TextMate grammar for Move Language to use in other environments. 4 | 5 | For full-featured IDE experience, use the [Move Extension](https://marketplace.visualstudio.com/items?itemName=mysten.move). 6 | 7 | To learn more about the language: 8 | 9 | - [The Move Book](https://move-book.com/) 10 | - [The Move Reference](https://move-book.com/reference) 11 | 12 | ## Highlighting examples 13 | 14 | With a dark theme: 15 | ![Move syntax highlighting](https://github.com/damirka/move-syntax/blob/main/img/sample_dark.png) 16 | 17 | With a light theme: 18 | ![Move syntax highlighting](https://github.com/damirka/move-syntax/blob/main/img/sample_light.png) 19 | 20 | ## Note for Extension Developers 21 | 22 | If you're building your own extension for Move, consider using this one for syntax highlighting. To do so, simply add this extension to the list of dependencies of your extension's `package.json` file: 23 | 24 | ```json 25 | "extensionDependencies": [ 26 | "damirka.move-syntax" 27 | ], 28 | ``` 29 | 30 | These extensions are already using this syntax highlighting: 31 | 32 | - [Move (marketplace)](https://marketplace.visualstudio.com/items?itemName=mysten.move) 33 | 34 | ## Contribution 35 | 36 | Feel free to ask any questions or report bugs [by opening new issue](https://github.com/damirka/move-syntax/issues). 37 | 38 | ## License 39 | 40 | [MIT](LICENSE). 41 | -------------------------------------------------------------------------------- /extension.js: -------------------------------------------------------------------------------- 1 | // nothing here.... -------------------------------------------------------------------------------- /img/logo.256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/damirka/move-syntax/4b04e9d614901097ffc0663fef40bd3e5d87779e/img/logo.256.png -------------------------------------------------------------------------------- /img/sample_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/damirka/move-syntax/4b04e9d614901097ffc0663fef40bd3e5d87779e/img/sample_dark.png -------------------------------------------------------------------------------- /img/sample_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/damirka/move-syntax/4b04e9d614901097ffc0663fef40bd3e5d87779e/img/sample_light.png -------------------------------------------------------------------------------- /language-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "comments": { 3 | // symbol used for single line comment. Remove this entry if your language does not support line comments 4 | "lineComment": "//", 5 | // symbols used for start and end a block comment. Remove this entry if your language does not support block comments 6 | "blockComment": [ "/*", "*/" ] 7 | }, 8 | // symbols used as brackets 9 | "brackets": [ 10 | ["{", "}"], 11 | ["[", "]"], 12 | ["(", ")"] 13 | ], 14 | // symbols that are auto closed when typing 15 | "autoClosingPairs": [ 16 | { "open": "{", "close": "}" }, 17 | { "open": "[", "close": "]" }, 18 | { "open": "(", "close": ")" }, 19 | { "open": "\"", "close": "\"", "notIn": ["string", "comment"] }, 20 | { "open": "<", "close": ">", "notIn": ["string", "comment"] } 21 | ], 22 | // symbols that that can be used to surround a selection 23 | "surroundingPairs": [ 24 | ["{", "}"], 25 | ["[", "]"], 26 | ["(", ")"], 27 | ["\"", "\""], 28 | ["<", ">"] 29 | ], 30 | "wordPattern": "[\\w_][\\w\\d-/_]*|`[\\w\\d-/_:.$]+`" 31 | } 32 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "move-syntax", 3 | "version": "0.4.7", 4 | "lockfileVersion": 2, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "move-syntax", 9 | "version": "0.4.7", 10 | "license": "MIT", 11 | "engines": { 12 | "vscode": "^1.43.0" 13 | } 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "move-syntax", 3 | "version": "0.7.1", 4 | "description": "Move syntax for VSCode", 5 | "publisher": "damirka", 6 | "displayName": "Move syntax", 7 | "categories": [ 8 | "Programming Languages", 9 | "Snippets", 10 | "Other" 11 | ], 12 | "engines": { 13 | "vscode": "^1.75.0" 14 | }, 15 | "main": "./extension.js", 16 | "browser": "./extension.js", 17 | "contributes": { 18 | "languages": [ 19 | { 20 | "id": "move", 21 | "aliases": [ 22 | "Move" 23 | ], 24 | "extensions": [ 25 | ".move" 26 | ], 27 | "configuration": "./language-configuration.json" 28 | } 29 | ], 30 | "grammars": [ 31 | { 32 | "language": "move", 33 | "scopeName": "source.move", 34 | "path": "./syntaxes/move.tmLanguage.json" 35 | }, 36 | { 37 | "scopeName": "text.html.markdown.move.codeblock", 38 | "path": "./syntaxes/move-markdown-injection.json", 39 | "injectTo": [ 40 | "text.html.markdown" 41 | ], 42 | "embeddedLanguages": { 43 | "meta.embedded.block.move": "move" 44 | } 45 | }, 46 | { 47 | "scopeName": "text.html.mdx.move.codeblock", 48 | "path": "./syntaxes/move-mdx-injection.json", 49 | "injectTo": [ 50 | "source.mdx" 51 | ], 52 | "embeddedLanguages": { 53 | "meta.embedded.block.move": "move" 54 | } 55 | } 56 | ] 57 | }, 58 | "icon": "img/logo.256.png", 59 | "galleryBanner": { 60 | "color": "#FFFFFF", 61 | "theme": "light" 62 | }, 63 | "repository": { 64 | "type": "git", 65 | "url": "https://github.com/damirka/vscode-move-syntax.git" 66 | }, 67 | "keywords": [ 68 | "libra", 69 | "move", 70 | "ide", 71 | "move syntax", 72 | "move ide", 73 | "move-ide", 74 | "libra-ide", 75 | "diem", 76 | "sui", 77 | "starcoin", 78 | "aptos" 79 | ], 80 | "author": "Damir Shamanaev ", 81 | "license": "MIT", 82 | "bugs": { 83 | "url": "https://github.com/damirka/vscode-move-syntax/issues" 84 | }, 85 | "homepage": "https://github.com/damirka/vscode-move-syntax#readme", 86 | "__metadata": { 87 | "id": "079cf480-3f72-452f-b128-8b8038c252fb", 88 | "publisherId": "a21ee11b-2c64-42b1-a3d1-78e5ee8191a6", 89 | "publisherDisplayName": "Damir Shamanaev" 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /sample/2024.move: -------------------------------------------------------------------------------- 1 | module 0x0::2024; 2 | 3 | #[deprecated(note = say_hello, haha = b"hahaaaha")] 4 | #[test, test_only] 5 | #[test, allow(unused_function)] 6 | public(package) fun haha( 7 | mut self: &mut Republic, 8 | a: u64 9 | ) { 10 | use std::vector::push_back as veckie; 11 | 12 | @alice 13 | self.field + 200; 14 | @alice 15 | 16 | break 'loop' 17 | 18 | let beep = ( 19 | a.call< u8 >( 20 | { @alice }, 21 | if (100 > true) { }, 22 | vector[ 23 | 100u8 24 | ] 25 | } ) as u8); 26 | 27 | vector>[ 28 | expr() 29 | ] 30 | 31 | 32 | vector> [ 33 | 34 | vector[ 35 | 10u64, 36 | 1000u128 37 | ], { 38 | if ( haha.inner.a().path( ) ) () else { 39 | hehe.aaaa.beep() 40 | } 41 | } 42 | ]; 43 | 44 | 45 | assert!() 46 | 47 | damir(); 48 | 49 | { 50 | id: , 51 | } 52 | 53 | 54 | self.column.heep; 55 | self.simple_call().aaa(); 56 | self.chained() 57 | .call< >( ( { { ( ) } } ) ); 58 | 59 | x"0222aaa" 60 | b"aaaa" 61 | 62 | 0x2 @0xAAAA 63 | } 64 | -------------------------------------------------------------------------------- /sample/2024_struct.move: -------------------------------------------------------------------------------- 1 | module foo::bar { 2 | 3 | // Imports 4 | 5 | use fun Self::foo as X.f1; 6 | use fun a::m::foo as X.f2; 7 | 8 | use fun foo as Self::X.f3; 9 | use fun foo as a::m::X.f4; 10 | 11 | use fun foo as X.f5; 12 | 13 | public use fun Self::foo as X.g1; 14 | public use fun a::m::foo as X.g2; 15 | 16 | public use fun foo as Self::X.g3; 17 | public use fun foo as a::m::X.g4; 18 | 19 | public use fun foo as X.g5; 20 | 21 | // Types 22 | 23 | public struct X {} 24 | 25 | public struct Old has key { 26 | x: u64 27 | } 28 | 29 | public struct NewPost has key (u64 vector(), u64) 30 | 31 | public struct NewPoster(u64) has key, store; 32 | 33 | public struct None() 34 | 35 | public enum NewEnum { 36 | V(), 37 | V1(u64, bool), 38 | V2 { x: u64, y: bool }, 39 | V3 40 | } 41 | 42 | public enum NewEnum has key { 43 | NewVariant(u64), 44 | VariantNoParams, 45 | VariantEmptyParams(), 46 | VariantNamedParams { x: u64 }, 47 | } 48 | 49 | public fun new(mut x: T): T { 50 | } 51 | 52 | public fun new_let_mut(): u64 { 53 | let mut x = 0; 54 | x = 1; 55 | let t = x.new(); 56 | let t = x.new(a, b, t.y()); 57 | let Old { mut y } = x.new(); 58 | let NewPost(y) = x.new(); 59 | let NewPoster(mut y) = x.new(); 60 | let NewPoster(mut y, z, i) = x.new(); 61 | let NewPoster(mut y, z, i) = x.new(); 62 | let NewPoster::Variant(mut y, z, i) = x.new(); 63 | 64 | let x = match x { 65 | NewEnum::V() => 0, 66 | NewEnum::V1(a, b) => {}, 67 | NewEnum::V2 { x, y } => x, 68 | NewEnum::V3 => 0, 69 | }; 70 | 71 | x.foreach!(|y| { x = y; }); 72 | assert!(x == 1, 6); 73 | x 74 | } 75 | 76 | // blocks 77 | public fun block() { 78 | 'a: { 79 | return 'a x; 80 | break 'a x; 81 | return'a x.foo!(); 82 | break'a { x = x + 1; x }; 83 | continue 'a; 84 | }; 85 | 'a: loop { }; 86 | 'a: while (true) { }; 87 | while (true) 'a: { }; 88 | // TODO: fix precedence of this 89 | if (true) 1 else 'a: { 2 } + 1; 90 | } 91 | 92 | // Macros 93 | macro fun ignore( 94 | _: None, 95 | ) {} 96 | 97 | macro fun for($start: u64, $stop: u64, $body: |u64|) { 98 | let mut i = $start; 99 | let stop = $stop; 100 | while (i < stop) { 101 | $body(i); 102 | i = i + 1 103 | } 104 | } 105 | 106 | macro fun for_each<$T>($v: &vector<$T>, $body: |&$T|) { 107 | let v = $v; 108 | let mut i = 0; 109 | let n = v.length(); 110 | while (i < n) { 111 | $body(v.borrow(i)); 112 | i = i + 1 113 | } 114 | } 115 | 116 | macro fun new<$T>($len: u64, $f: |u64| -> $T): vector<$T> { 117 | let len = $len; 118 | let mut v = vector[]; 119 | for!(0, len, |i| v.push_back($f(i))); 120 | v 121 | } 122 | 123 | macro fun sum($v: &vector): u64 { 124 | let mut s = 0; 125 | for_each!($v, |i| s = s + *i); 126 | s 127 | } 128 | 129 | fun t() { 130 | None().ignore!() 131 | } 132 | 133 | entry fun main() { 134 | let v = new!(10, |i| i); 135 | assert!(sum!(&v) == 45, 0); 136 | } 137 | 138 | public struct Cup has drop {} 139 | public macro fun foo( 140 | _: ||, 141 | _: || -> (), 142 | _: || -> u64, 143 | _: || -> (u64), 144 | _: || -> (u64, bool), 145 | _: |&u64|, 146 | _: |&u64| -> (), 147 | _: |&u64| -> u64, 148 | _: |&u64| -> (u64), 149 | _: |&u64| -> (u64, bool), 150 | _: |bool, address|, 151 | _: |bool, address| -> (), 152 | _: |bool, address| -> u64, 153 | _: |bool, address| -> (u64), 154 | _: |bool, address| -> (u64, bool), 155 | _: |bool, address| -> (u64, bool, &u64), 156 | _: || -> || -> ||, 157 | _: || -> || -> || -> || -> (), 158 | _: || -> | | -> || -> | | -> u64, 159 | _: | | -> || -> | | -> || -> (u64), 160 | _: Cup<||>, 161 | _: Cup<|| -> u64>, 162 | ) {} 163 | 164 | macro fun call<$T>($f: || -> $T): $T { 165 | $f() 166 | } 167 | 168 | fun t() { 169 | call!(|| -> u64 'a: { 0 }); 170 | } 171 | 172 | fun t() { 173 | call!(|| -> () { }); 174 | call!(|| -> () { () }); 175 | call!(|| -> u64 { 0 }); 176 | call!(|| -> (u64, u8) { (0, 0) }); 177 | } 178 | } 179 | -------------------------------------------------------------------------------- /sample/broken_sample.move: -------------------------------------------------------------------------------- 1 | module base_addr_module::base_module { 2 | 3 | public struct A { 4 | f1: bool, 5 | f2: T 6 | } 7 | 8 | public fun return_0(): u64 { abort 42 } 9 | 10 | public fun plus_1_fun(x: u64): u64 { x + 1 } 11 | 12 | public(package) fun friend_fun(x: u64): u64 { x } 13 | 14 | fun non_public_fun(y: bool): u64 { if (y) 0 else 1 } 15 | 16 | entry fun entry_fun() { } 17 | 18 | public fun string() { 19 | b"\\".to_string() 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /sample/label_module_suffix.move: -------------------------------------------------------------------------------- 1 | module aaa_module::option_module; 2 | 3 | use std::vector; 4 | -------------------------------------------------------------------------------- /syntaxes/move-markdown-injection.json: -------------------------------------------------------------------------------- 1 | { 2 | "fileTypes": [], 3 | "injectionSelector": "L:text.html.markdown", 4 | "patterns": [ 5 | { 6 | "include": "#move-code-block" 7 | } 8 | ], 9 | "repository": { 10 | "move-code-block": { 11 | "begin": "(^|\\G)(\\s*)(\\`{3,}|~{3,})\\s*(?i:(move)(\\s+[^`~]*)?$)", 12 | "name": "markup.fenced_code.block.markdown", 13 | "end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$", 14 | "beginCaptures": { 15 | "3": { 16 | "name": "punctuation.definition.markdown" 17 | }, 18 | "4": { 19 | "name": "fenced_code.block.language.markdown" 20 | }, 21 | "5": { 22 | "name": "fenced_code.block.language.attributes.markdown" 23 | } 24 | }, 25 | "endCaptures": { 26 | "3": { 27 | "name": "punctuation.definition.markdown" 28 | } 29 | }, 30 | "patterns": [ 31 | { 32 | "begin": "(^|\\G)(\\s*)(.*)", 33 | "while": "(^|\\G)(?!\\s*([`~]{3,})\\s*$)", 34 | "contentName": "meta.embedded.block.move", 35 | "patterns": [ 36 | { "include": "source.move#comments" }, 37 | { "include": "source.move#comments" }, 38 | { "include": "source.move#module" }, 39 | { "include": "source.move#script" }, 40 | { "include": "source.move#annotation" }, 41 | { "include": "source.move#entry" }, 42 | { "include": "source.move#public-scope" }, 43 | { "include": "source.move#public" }, 44 | { "include": "source.move#macro" }, 45 | { "include": "source.move#native" }, 46 | { "include": "source.move#import" }, 47 | { "include": "source.move#friend" }, 48 | { "include": "source.move#const" }, 49 | { "include": "source.move#struct" }, 50 | { "include": "source.move#enum" }, 51 | { "include": "source.move#fun" }, 52 | { "include": "source.move#spec" }, 53 | { "include": "source.move#as" }, 54 | { "include": "source.move#mut" }, 55 | { "include": "source.move#let" }, 56 | { "include": "source.move#types" }, 57 | { "include": "source.move#assert" }, 58 | { "include": "source.move#literals" }, 59 | { "include": "source.move#control" }, 60 | { "include": "source.move#move_copy" }, 61 | { "include": "source.move#resource_methods" }, 62 | { "include": "source.move#self_access" }, 63 | { "include": "source.move#module_access" }, 64 | { "include": "source.move#fun_call" }, 65 | { "include": "source.move#block" } 66 | ] 67 | } 68 | ] 69 | } 70 | }, 71 | "scopeName": "markdown.move.codeblock" 72 | } 73 | -------------------------------------------------------------------------------- /syntaxes/move-mdx-injection.json: -------------------------------------------------------------------------------- 1 | { 2 | "fileTypes": [], 3 | "scopeName": "mdx.move.codeblock", 4 | "injectionSelector": "L:source.mdx", 5 | "patterns": [ 6 | { 7 | "begin": "(?:^|\\G)[\\t ]*(`{3,})(?:[\\t ]*((?i:(?:.*\\.)?move))(?:[\\t ]+((?:[^\\n\\r`])+))?)(?:[\\t ]*$)", 8 | "beginCaptures": { 9 | "1": { 10 | "name": "string.other.begin.code.fenced.mdx" 11 | }, 12 | "2": { 13 | "name": "entity.name.function.mdx" 14 | } 15 | }, 16 | "contentName": "meta.embedded.move", 17 | "end": "(\\1)(?:[\\t ]*$)", 18 | "endCaptures": { 19 | "1": { 20 | "name": "string.other.end.code.fenced.mdx" 21 | } 22 | }, 23 | "name": "markup.code.move.mdx", 24 | "patterns": [ 25 | { 26 | "include": "source.move" 27 | } 28 | ] 29 | }, 30 | { 31 | "begin": "(?:^|\\G)[\\t ]*(~{3,})(?:[\\t ]*((?i:(?:.*\\.)?move))(?:[\\t ]+((?:[^\\n\\r])+))?)(?:[\\t ]*$)", 32 | "beginCaptures": { 33 | "1": { 34 | "name": "string.other.begin.code.fenced.mdx" 35 | }, 36 | "2": { 37 | "name": "entity.name.function.mdx" 38 | } 39 | }, 40 | "contentName": "meta.embedded.move", 41 | "end": "(\\1)(?:[\\t ]*$)", 42 | "endCaptures": { 43 | "1": { 44 | "name": "string.other.end.code.fenced.mdx" 45 | } 46 | }, 47 | "name": "markup.code.move.mdx", 48 | "patterns": [ 49 | { 50 | "include": "source.move" 51 | } 52 | ] 53 | } 54 | ] 55 | } 56 | -------------------------------------------------------------------------------- /syntaxes/move.tmLanguage.json: -------------------------------------------------------------------------------- 1 | { 2 | "scopeName": "source.move", 3 | "repository": { 4 | "doc-comments": { 5 | "comment": "Documentation comment", 6 | "name": "comment.block.documentation.move", 7 | "begin": "///", 8 | "end": "$", 9 | "patterns": [ 10 | { 11 | "comment": "Escaped member / link", 12 | "match": "`(\\w+)`", 13 | "captures": { 14 | "1": { "name": "markup.underline.link.move" } 15 | } 16 | } 17 | ] 18 | }, 19 | "line-comments": { 20 | "comment": "Single-line comment", 21 | "name": "comment.line.double-slash.move", 22 | "begin": "//", 23 | "end": "$" 24 | }, 25 | "block-comments": { 26 | "patterns": [ 27 | { 28 | "comment": "Block documentation comment", 29 | "name": "comment.block.documentation.move", 30 | "begin": "/\\*[\\*!](?![\\*/])", 31 | "end": "\\*/" 32 | }, 33 | { 34 | "comment": "Block comment", 35 | "name": "comment.block.move", 36 | "begin": "/\\*", 37 | "end": "\\*/" 38 | } 39 | ] 40 | }, 41 | "comments": { 42 | "name": "meta.comments.move", 43 | "patterns": [ 44 | { "include": "#doc-comments" }, 45 | { "include": "#line-comments" }, 46 | { "include": "#block-comments" } 47 | ] 48 | }, 49 | 50 | "annotation": { 51 | "name": "support.constant.annotation.move", 52 | "begin": "#\\[", 53 | "end": "\\]", 54 | "patterns": [ 55 | { 56 | "comment": "Annotation name", 57 | "name": "meta.annotation.name.move", 58 | "match": "\\b(\\w+)\\s*(?=\\=)" 59 | }, 60 | { 61 | "comment": "Annotation value", 62 | "name": "meta.annotation.value.move", 63 | "begin": "=", 64 | "end": "(?=[,\\]])", 65 | "patterns": [{ "include": "#literals" }] 66 | } 67 | ] 68 | }, 69 | 70 | "script": { 71 | "name": "meta.script.move", 72 | "begin": "\\b(script)\\b", 73 | "beginCaptures": { 74 | "1": { "name": "storage.modifier.script.move" } 75 | }, 76 | "end": "(?<=})", 77 | "patterns": [ 78 | { "include": "#comments" }, 79 | { 80 | "name": "meta.script_scope.move", 81 | "comment": "Script scope", 82 | "begin": "{", 83 | "end": "}", 84 | "patterns": [ 85 | { "include": "#const" }, 86 | { "include": "#comments" }, 87 | { "include": "#import" }, 88 | { "include": "#fun" } 89 | ] 90 | } 91 | ] 92 | }, 93 | 94 | "address": { 95 | "name": "meta.address_block.move", 96 | "comment": "Address block", 97 | "begin": "\\b(address)\\b", 98 | "end": "(?<=})", 99 | "beginCaptures": { 100 | "1": { "name": "storage.modifier.type.address.keyword.move" } 101 | }, 102 | "patterns": [ 103 | { "include": "#comments" }, 104 | { 105 | "name": "meta.address.definition.move", 106 | "comment": "Address value/const", 107 | "begin": "(?<=address)", 108 | "end": "(?=[{])", 109 | "patterns": [ 110 | { "include": "#comments" }, 111 | { "include": "#address_literal" }, 112 | { 113 | "comment": "Named Address", 114 | "name": "entity.name.type.move", 115 | "match": "\\b(\\w+)\\b" 116 | } 117 | ] 118 | }, 119 | { "include": "#module" } 120 | ] 121 | }, 122 | 123 | "module_label": { 124 | "name": "meta.module.label.move", 125 | "comment": "Module label, inline module definition", 126 | "begin": "^\\s*(module)\\b", 127 | "end": ";\\s*$", 128 | "patterns": [ 129 | { "include": "#comments" }, 130 | { "include": "#escaped_identifier" }, 131 | { 132 | "comment": "Module namespace / address", 133 | "name": "constant.other.move", 134 | "begin": "(?<=\\bmodule\\b)", 135 | "end": "(?=[(::){])" 136 | }, 137 | { 138 | "comment": "Module name", 139 | "name": "entity.name.type.move", 140 | "begin": "(?<=::)", 141 | "end": "(?=[\\s{])" 142 | } 143 | ] 144 | }, 145 | 146 | "module": { 147 | "name": "meta.module.move", 148 | "comment": "Module definition", 149 | "begin": "\\b(module)\\b", 150 | "end": "(?<=[;}])", 151 | "beginCaptures": { 152 | "1": { "name": "storage.modifier.type.move" } 153 | }, 154 | "patterns": [ 155 | { "include": "#comments" }, 156 | { 157 | "comment": "Module name", 158 | "begin": "(?<=\\b(module)\\b)", 159 | "end": "(?=[;{])", 160 | "patterns": [ 161 | { "include": "#comments" }, 162 | { "include": "#escaped_identifier" }, 163 | { 164 | "comment": "Module namespace / address", 165 | "name": "constant.other.move", 166 | "begin": "(?<=\\b(module))", 167 | "end": "(?=[(::){])", 168 | "patterns": [ 169 | { "include": "#comments" }, 170 | { "include": "#escaped_identifier" } 171 | ] 172 | }, 173 | { 174 | "comment": "Module name", 175 | "name": "entity.name.type.move", 176 | "begin": "(?<=::)", 177 | "end": "(?=[\\s;{])", 178 | "patterns": [ 179 | { "include": "#comments" }, 180 | { "include": "#escaped_identifier" } 181 | ] 182 | } 183 | ] 184 | }, 185 | { 186 | "name": "meta.module_scope.move", 187 | "comment": "Module scope", 188 | "begin": "{", 189 | "end": "}", 190 | "patterns": [ 191 | { "include": "#comments" }, 192 | { "include": "#annotation" }, 193 | { "include": "#entry" }, 194 | { "include": "#public-scope" }, 195 | { "include": "#public" }, 196 | { "include": "#native" }, 197 | { "include": "#import" }, 198 | { "include": "#friend" }, 199 | { "include": "#const" }, 200 | 201 | { "include": "#struct" }, 202 | { "include": "#has_ability" }, 203 | 204 | { "include": "#enum" }, 205 | { "include": "#macro" }, 206 | { "include": "#fun" }, 207 | { "include": "#spec" } 208 | ] 209 | } 210 | ] 211 | }, 212 | 213 | "use_fun": { 214 | "comment": "use { fun } internals", 215 | "name": "meta.import.fun.move", 216 | "begin": "\\b(fun)\\b", 217 | "beginCaptures": { 218 | "1": { "name": "storage.modifier.fun.move" } 219 | }, 220 | "end": "(?=;)", 221 | "patterns": [ 222 | { "include": "#comments" }, 223 | { 224 | "comment": "as keyword", 225 | "match": "\\b(as)\\b", 226 | "name": "keyword.control.as.move" 227 | }, 228 | { 229 | "comment": "Self keyword", 230 | "match": "\\b(Self)\\b", 231 | "name": "variable.language.self.use.fun.move" 232 | }, 233 | { 234 | "comment": "Function name", 235 | "name": "entity.name.function.use.move", 236 | "match": "\\b(_______[a-z][a-z_0-9]+)\\b" 237 | }, 238 | { "include": "#types" }, 239 | { "include": "#escaped_identifier" }, 240 | { "include": "#capitalized" } 241 | ] 242 | }, 243 | 244 | "public-scope": { 245 | "comment": "public (friend/script/package)", 246 | "name": "meta.public.scoped.move", 247 | "begin": "(?<=\\b(public))\\s*\\(", 248 | "end": "\\)", 249 | "patterns": [ 250 | { "include": "#comments" }, 251 | { 252 | "match": "\\b(friend|script|package)\\b", 253 | "name": "keyword.control.public.scope.move" 254 | } 255 | ] 256 | }, 257 | 258 | "public": { 259 | "comment": "public", 260 | "match": "\\b(public)\\b", 261 | "name": "storage.modifier.visibility.public.move" 262 | }, 263 | 264 | "entry": { 265 | "comment": "entry", 266 | "match": "\\b(entry)\\b", 267 | "name": "storage.modifier.visibility.entry.move" 268 | }, 269 | 270 | "native": { 271 | "comment": "native", 272 | "match": "\\b(native)\\b", 273 | "name": "storage.modifier.visibility.native.move" 274 | }, 275 | 276 | "inline": { 277 | "comment": "inline", 278 | "match": "\\b(inline)\\b", 279 | "name": "storage.modifier.visibility.inline.move" 280 | }, 281 | 282 | "import": { 283 | "name": "meta.import.move", 284 | "begin": "\\b(use)\\b", 285 | "beginCaptures": { 286 | "1": { "name": "storage.modifier.type.move" } 287 | }, 288 | "end": ";", 289 | "patterns": [ 290 | { "include": "#comments" }, 291 | { "include": "#use_fun" }, 292 | { "include": "#address_literal" }, 293 | { "include": "#as-import" }, 294 | { 295 | "comment": "Uppercase entities", 296 | "match": "\\b([A-Z]\\w*)\\b", 297 | "name": "entity.name.type.move" 298 | }, 299 | { 300 | "comment": "Module members", 301 | "begin": "{", 302 | "end": "}", 303 | "patterns": [ 304 | { "include": "#comments" }, 305 | { "include": "#as-import" }, 306 | { 307 | "comment": "Uppercase entities", 308 | "match": "\\b([A-Z]\\w*)\\b", 309 | "name": "entity.name.type.move" 310 | } 311 | ] 312 | }, 313 | { 314 | "comment": "Name of the imported module", 315 | "match": "\\b(\\w+)\\b", 316 | "name": "meta.entity.name.type.module.move" 317 | } 318 | ] 319 | }, 320 | 321 | "friend": { 322 | "name": "meta.friend.move", 323 | "begin": "\\b(friend)\\b", 324 | "beginCaptures": { 325 | "1": { "name": "storage.modifier.type.move" } 326 | }, 327 | "end": ";", 328 | "patterns": [ 329 | { "include": "#comments" }, 330 | { "include": "#address_literal" }, 331 | { 332 | "comment": "Name of the imported module", 333 | "match": "\\b([a-zA-Z][A-Za-z_0-9]*)\\b", 334 | "name": "entity.name.type.module.move" 335 | } 336 | ] 337 | }, 338 | 339 | "const": { 340 | "name": "meta.const.move", 341 | "begin": "\\b(const)\\b", 342 | "beginCaptures": { 343 | "1": { "name": "storage.modifier.const.move" } 344 | }, 345 | "end": ";", 346 | "patterns": [ 347 | { "include": "#comments" }, 348 | { "include": "#primitives" }, 349 | { "include": "#literals" }, 350 | { "include": "#types" }, 351 | { 352 | "match": "\\b([A-Z][A-Z_0-9]+)\\b", 353 | "name": "constant.other.move" 354 | }, 355 | { "include": "#error_const" } 356 | ] 357 | }, 358 | 359 | "has_ability": { 360 | "name": "meta.has.ability.move", 361 | "begin": "(?<=[})])\\s+(has)\\b", 362 | "end": ";", 363 | "beginCaptures": { 364 | "1": { "name": "storage.modifier.type.move" } 365 | }, 366 | "patterns": [ 367 | { "include": "#comments" }, 368 | { "include": "#abilities" } 369 | ] 370 | }, 371 | 372 | "struct": { 373 | "name": "meta.struct.move", 374 | "begin": "\\b(struct)\\b", 375 | "beginCaptures": { 376 | "1": { "name": "storage.modifier.type.move" } 377 | }, 378 | "end": "(?<=[};\\)])", 379 | "patterns": [ 380 | { "include": "#comments" }, 381 | { "include": "#escaped_identifier" }, 382 | 383 | { "include": "#has" }, 384 | { "include": "#abilities" }, 385 | { 386 | "comment": "Struct name (ident)", 387 | "match": "\\b[A-Z][a-zA-Z_0-9]*\\b", 388 | "name": "entity.name.type.struct.move" 389 | }, 390 | { 391 | "name": "meta.struct.paren.move", 392 | "comment": "Positional fields", 393 | "begin": "\\(", 394 | "end": "\\)", 395 | "patterns": [ 396 | { "include": "#comments" }, 397 | { "include": "#capitalized" }, 398 | { "include": "#types" } 399 | ] 400 | }, 401 | { "include": "#type_param" }, 402 | { 403 | "name": "meta.struct.paren.move", 404 | "comment": "Simple struct", 405 | "begin": "\\(", 406 | "end": "(?<=[)])", 407 | "patterns": [ 408 | { "include": "#comments" }, 409 | { "include": "#types" } 410 | ] 411 | }, 412 | { 413 | "name": "meta.struct.body.move", 414 | "comment": "Struct body", 415 | "begin": "{", 416 | "end": "}", 417 | "patterns": [ 418 | { "include": "#comments" }, 419 | { "include": "#self_access" }, 420 | { "include": "#escaped_identifier" }, 421 | { "include": "#module_access" }, 422 | { "include": "#expr_generic" }, 423 | { "include": "#capitalized" }, 424 | { "include": "#types" } 425 | ] 426 | }, 427 | { "include": "#has_ability" } 428 | ] 429 | }, 430 | 431 | "enum": { 432 | "comment": "Enum syntax", 433 | "name": "meta.enum.move", 434 | "begin": "\\b(enum)\\b", 435 | "beginCaptures": { 436 | "1": { "name": "keyword.control.enum.move" } 437 | }, 438 | "end": "(?<=})", 439 | "patterns": [ 440 | { "include": "#comments" }, 441 | { "include": "#escaped_identifier" }, 442 | { "include": "#type_param" }, 443 | { 444 | "comment": "Enum name (ident)", 445 | "match": "\\b[A-Z][a-zA-Z_0-9]*\\b", 446 | "name": "entity.name.type.enum.move" 447 | }, 448 | { "include": "#has" }, 449 | { "include": "#abilities" }, 450 | { 451 | "name": "meta.enum.definition.move", 452 | "begin": "{", 453 | "end": "}", 454 | "patterns": [ 455 | { "include": "#comments" }, 456 | { 457 | "name": "entity.name.function.enum.move", 458 | "match": "\\b([A-Z][A-Za-z_0-9]*)\\b(?=\\s*\\()" 459 | }, 460 | { 461 | "name": "entity.name.type.enum.move", 462 | "match": "\\b([A-Z][A-Za-z_0-9]*)\\b" 463 | }, 464 | { 465 | "name": "meta.enum.tuple.move", 466 | "begin": "\\(", 467 | "end": "\\)", 468 | "patterns": [ 469 | { "include": "#comments" }, 470 | { "include": "#expr_generic" }, 471 | { "include": "#capitalized" }, 472 | { "include": "#types" } 473 | ] 474 | }, 475 | { 476 | "name": "meta.enum.struct.move", 477 | "begin": "{", 478 | "end": "}", 479 | "patterns": [ 480 | { "include": "#comments" }, 481 | { "include": "#escaped_identifier" }, 482 | { "include": "#expr_generic" }, 483 | { "include": "#capitalized" }, 484 | { "include": "#types" } 485 | ] 486 | } 487 | ] 488 | } 489 | ] 490 | }, 491 | 492 | "has": { 493 | "comment": "Has Abilities", 494 | "match": "\\b(has)\\b", 495 | "name": "keyword.control.ability.has.move" 496 | }, 497 | 498 | "macro": { 499 | "comment": "macro fun [ident] {}", 500 | "name": "meta.macro.move", 501 | "begin": "\\b(macro)\\b", 502 | "end": "(?<=})", 503 | "beginCaptures": { 504 | "1": { "name": "keyword.control.macro.move" } 505 | }, 506 | "patterns": [{ "include": "#comments" }, { "include": "#fun" }] 507 | }, 508 | 509 | "fun": { 510 | "patterns": [ 511 | { "include": "#fun_signature" }, 512 | { "include": "#block" } 513 | ] 514 | }, 515 | 516 | "fun_signature": { 517 | "name": "meta.fun_signature.move", 518 | "comment": "Function signature", 519 | "begin": "\\b(fun)\\b", 520 | "beginCaptures": { 521 | "1": { "name": "storage.modifier.fun.move" } 522 | }, 523 | "end": "(?=[;{])", 524 | "patterns": [ 525 | { "include": "#comments" }, 526 | { "include": "#module_access" }, 527 | { "include": "#capitalized" }, 528 | { "include": "#types" }, 529 | { "include": "#mut" }, 530 | { 531 | "name": "meta.function_name.move", 532 | "comment": "Function name", 533 | "begin": "(?<=\\bfun)", 534 | "end": "(?=[<(])", 535 | "patterns": [ 536 | { "include": "#comments" }, 537 | { "include": "#escaped_identifier" }, 538 | { 539 | "name": "entity.name.function.move", 540 | "match": "\\b(\\w+)\\b" 541 | } 542 | ] 543 | }, 544 | { "include": "#type_param" }, 545 | { 546 | "name": "meta.parentheses.move", 547 | "comment": "Parentheses", 548 | "begin": "[(]", 549 | "end": "[)]", 550 | "patterns": [ 551 | { "include": "#comments" }, 552 | { "include": "#self_access" }, 553 | { "include": "#expr_generic" }, 554 | { "include": "#escaped_identifier" }, 555 | { "include": "#module_access" }, 556 | { "include": "#capitalized" }, 557 | { "include": "#types" }, 558 | { "include": "#mut" } 559 | ] 560 | }, 561 | { 562 | "comment": "Keyword acquires", 563 | "match": "\\b(acquires)\\b", 564 | "name": "storage.modifier" 565 | } 566 | ] 567 | }, 568 | 569 | "type_param": { 570 | "name": "meta.generic_param.move", 571 | "comment": "Generic type param", 572 | "begin": "<", 573 | "end": ">", 574 | "patterns": [ 575 | { "include": "#comments" }, 576 | { "include": "#phantom" }, 577 | { "include": "#capitalized" }, 578 | { "include": "#module_access" }, 579 | { "include": "#abilities" } 580 | ] 581 | }, 582 | 583 | "abilities": { 584 | "comment": "Ability", 585 | "match": "\\b(store|key|drop|copy)\\b", 586 | "name": "support.type.ability.move" 587 | }, 588 | 589 | "fun_body": { 590 | "name": "meta.fun_body.move", 591 | "comment": "Function body", 592 | "begin": "{", 593 | "end": "(?<=})", 594 | "patterns": [{ "include": "#expr" }] 595 | }, 596 | 597 | "ident": { 598 | "name": "meta.identifier.move", 599 | "match": "\\b([a-zA-Z][A-Z_a-z0-9]*)\\b" 600 | }, 601 | 602 | "paren": { 603 | "name": "meta.paren.move", 604 | "begin": "\\(", 605 | "end": "\\)", 606 | "patterns": [{ "include": "#expr" }] 607 | }, 608 | 609 | "label": { 610 | "comment": "Label", 611 | "match": "'[a-z][a-z_0-9]*", 612 | "name": "string.quoted.single.label.move" 613 | }, 614 | 615 | "block": { 616 | "name": "meta.block.move", 617 | "comment": "Block expression or definition", 618 | "begin": "{", 619 | "end": "}", 620 | "patterns": [{ "include": "#expr" }] 621 | }, 622 | 623 | "phantom": { 624 | "comment": "Keyword phantom inside type parameters", 625 | "match": "\\b(phantom)\\b", 626 | "name": "keyword.control.phantom.move" 627 | }, 628 | 629 | "let": { 630 | "comment": "Keyword let", 631 | "match": "\\b(let)\\b", 632 | "name": "keyword.control.move" 633 | }, 634 | 635 | "move_copy": { 636 | "comment": "Keywords move and copy", 637 | "match": "\\b(move|copy)\\b", 638 | "name": "variable.language.move" 639 | }, 640 | 641 | "control": { 642 | "comment": "Control flow", 643 | "match": "\\b(return|while|loop|if|else|break|continue|abort)\\b", 644 | "name": "keyword.control.move" 645 | }, 646 | 647 | "as-import": { 648 | "comment": "Keyword as in import statement; not highlighted", 649 | "name": "meta.import.as.move", 650 | "match": "\\b(as)\\b" 651 | }, 652 | 653 | "as": { 654 | "comment": "Keyword as (highlighted)", 655 | "match": "\\b(as)\\b", 656 | "name": "keyword.control.as.move" 657 | }, 658 | 659 | "mut": { 660 | "comment": "Mutable reference and let mut", 661 | "match": "\\b(mut)\\b", 662 | "name": "storage.modifier.mut.move" 663 | }, 664 | 665 | "escaped_identifier": { 666 | "comment": "Escaped variable", 667 | "begin": "`", 668 | "end": "`", 669 | "name": "variable.language.escaped.move" 670 | }, 671 | 672 | "resource_methods": { 673 | "comment": "Methods to work with resource", 674 | "match": "\\b(borrow_global|borrow_global_mut|exists|move_from|move_to_sender|move_to)\\b", 675 | "name": "support.function.typed.move" 676 | }, 677 | 678 | "macro_call": { 679 | "name": "meta.macro.call", 680 | "comment": "Macro fun call", 681 | "match": "(\\b|\\.)([a-z][A-Za-z0-9_]*)!", 682 | "captures": { 683 | "2": { "name": "support.function.macro.move" } 684 | } 685 | }, 686 | 687 | "vector": { 688 | "comment": "vector type", 689 | "match": "\\b(vector)\\b", 690 | "name": "support.type.vector.move" 691 | }, 692 | 693 | "self_access": { 694 | "name": "meta.self_access.move", 695 | "comment": "Use of Self", 696 | "match": "\\b(Self)::(\\w+)\\b", 697 | "captures": { 698 | "1": { "name": "variable.language.self.move" }, 699 | "2": { "name": "entity.name.function.call.move" } 700 | } 701 | }, 702 | 703 | "module_access": { 704 | "name": "meta.module_access.move", 705 | "comment": "Use of module type or method", 706 | "match": "\\b(\\w+)::(\\w+)\\b", 707 | "captures": { 708 | "1": { "name": "meta.entity.name.type.accessed.module.move" }, 709 | "2": { "name": "entity.name.function.call.move" } 710 | } 711 | }, 712 | 713 | "error_const": { 714 | "name": "variable.other.error.const.move", 715 | "match": "\\b(E[A-Z][A-Za-z0-9_]*)\\b" 716 | }, 717 | 718 | "capitalized": { 719 | "comment": "MyType - capitalized type name", 720 | "name": "entity.name.type.use.move", 721 | "match": "\\b([A-Z][a-zA-Z_0-9]*)\\b" 722 | }, 723 | 724 | "types": { 725 | "name": "meta.types.move", 726 | "comment": "Built-in types + vector", 727 | "patterns": [{ "include": "#primitives" }, { "include": "#vector" }] 728 | }, 729 | 730 | "struct_pack": { 731 | "comment": "Struct { field: value... }; identified as generic / ident followed by curly's", 732 | "name": "meta.struct.pack.move", 733 | "begin": "(?<=[A-Za-z0-9_>])\\s*{", 734 | "end": "}", 735 | "patterns": [{ "include": "#comments" }] 736 | }, 737 | 738 | "primitives": { 739 | "comment": "Primitive types", 740 | "match": "\\b(u8|u16|u32|u64|u128|u256|address|bool|signer)\\b", 741 | "name": "support.type.primitives.move" 742 | }, 743 | 744 | "path_access": { 745 | "comment": ".[ident] access", 746 | "name": "meta.path.access.move", 747 | "match": "\\.[a-z][_a-z0-9]*\\b" 748 | }, 749 | 750 | "packed_field": { 751 | "comment": "[ident]: ", 752 | "name": "meta.struct.field.move", 753 | "match": "[a-z][a-z0-9_]+\\s*:\\s*(?=\\s)" 754 | }, 755 | 756 | "expr_generic": { 757 | "comment": "< angle brackets >", 758 | "name": "meta.expression.generic.type.move", 759 | "begin": "<(?=([\\sa-z_,0-9A-Z<>]+>))", 760 | "end": ">", 761 | "patterns": [ 762 | { "include": "#comments" }, 763 | { "include": "#types" }, 764 | { "include": "#capitalized" }, 765 | { "include": "#expr_generic" } 766 | ] 767 | }, 768 | 769 | "match_expression": { 770 | "comment": "enum pattern matching", 771 | "name": "meta.match.move", 772 | "begin": "\\b(match)\\b", 773 | "beginCaptures": { 774 | "1": { "name": "keyword.control.match.move" } 775 | }, 776 | "end": "(?<=})", 777 | "patterns": [ 778 | { "include": "#comments" }, 779 | { "include": "#escaped_identifier" }, 780 | { "include": "#types" }, 781 | { 782 | "name": "meta.match.block.move", 783 | "comment": "Block expression or definition", 784 | "begin": "{", 785 | "end": "}", 786 | "patterns": [ 787 | { 788 | "comment": "arrow operator", 789 | "match": "\\b(=>)\\b", 790 | "name": "operator.match.move" 791 | }, 792 | { "include": "#expr" } 793 | ] 794 | }, 795 | { "include": "#expr" } 796 | ] 797 | }, 798 | 799 | "method_call": { 800 | "comment": ".[ident]<>?() call", 801 | "name": "meta.path.call.move", 802 | "match": "\\.([a-z][_a-z0-9]*)(?=[<\\(])", 803 | "captures": { 804 | "1": { "name": "entity.name.function.call.path.move" } 805 | } 806 | }, 807 | 808 | "local_call": { 809 | "comment": "call to a local / imported fun", 810 | "name": "entity.name.function.call.local.move", 811 | "match": "\\b([a-z][_a-z0-9]*)(?=[<\\(])" 812 | }, 813 | 814 | "literals": { 815 | "comment": "Literals supported in Move", 816 | "name": "meta.literal.move", 817 | "patterns": [ 818 | { 819 | "comment": "base16 address literal", 820 | "match": "@0x[A-F0-9a-f]+", 821 | "name": "support.constant.address.base16.move" 822 | }, 823 | { 824 | "comment": "named address literal @[ident]", 825 | "match": "@[a-zA-Z][a-zA-Z_0-9]*", 826 | "name": "support.constant.address.name.move" 827 | }, 828 | { 829 | "comment": "Hex literal", 830 | "name": "constant.numeric.hex.move", 831 | "match": "0x[_a-fA-F0-9]+(?:u(?:8|16|32|64|128|256))?" 832 | }, 833 | { 834 | "comment": "Numeric literal", 835 | "name": "constant.numeric.move", 836 | "match": "(?)?\\s*[(]", 958 | "beginCaptures": { 959 | "1": { "name": "entity.name.function.call.move" } 960 | }, 961 | "end": "[)]", 962 | "patterns": [ 963 | { "include": "#comments" }, 964 | { "include": "#resource_methods" }, 965 | { "include": "#self_access" }, 966 | { "include": "#module_access" }, 967 | { "include": "#move_copy" }, 968 | { "include": "#literals" }, 969 | { "include": "#fun_call" }, 970 | { "include": "#block" }, 971 | { "include": "#mut" }, 972 | { "include": "#as" } 973 | ] 974 | }, 975 | 976 | "spec_block": { 977 | "comment": "Spec block", 978 | "name": "meta.spec_block.move", 979 | "begin": "{", 980 | "end": "}", 981 | "patterns": [ 982 | { "include": "#comments" }, 983 | { "include": "#spec_block" }, 984 | { "include": "#spec_types" }, 985 | { "include": "#fun_call" }, 986 | { "include": "#literals" }, 987 | { "include": "#control" }, 988 | { "include": "#types" }, 989 | { "include": "#let" } 990 | ] 991 | }, 992 | 993 | "spec_keywords": { 994 | "match": "\\b(global|pack|unpack|pragma|native|include|ensures|requires|invariant|apply|aborts_if|modifies)\\b", 995 | "name": "keyword.control.move.spec" 996 | }, 997 | 998 | "spec_define": { 999 | "comment": "Spec define keyword", 1000 | "name": "meta.spec_define.move", 1001 | "begin": "\\b(define)\\b", 1002 | "beginCaptures": { 1003 | "1": { "name": "keyword.control.move.spec" } 1004 | }, 1005 | "end": "(?=[;{])", 1006 | "patterns": [ 1007 | { "include": "#comments" }, 1008 | { "include": "#spec_types" }, 1009 | { "include": "#types" }, 1010 | { 1011 | "comment": "Function name", 1012 | "begin": "(?<=\\bdefine)", 1013 | "end": "(?=[(])", 1014 | "patterns": [ 1015 | { "include": "#comments" }, 1016 | { 1017 | "name": "entity.name.function.move", 1018 | "match": "\\b(\\w+)\\b" 1019 | } 1020 | ] 1021 | } 1022 | ] 1023 | }, 1024 | 1025 | "spec_types": { 1026 | "comment": "Spec-only types", 1027 | "match": "\\b(range|num|vector|bool|u8|u16|u32|u64|u128|u256|address)\\b", 1028 | "name": "support.type.vector.move" 1029 | }, 1030 | 1031 | "spec": { 1032 | "name": "meta.spec.move", 1033 | "begin": "\\b(spec)\\b", 1034 | "beginCaptures": { 1035 | "1": { "name": "storage.modifier.spec.move" } 1036 | }, 1037 | "end": "(?<=[;}])", 1038 | "patterns": [ 1039 | { 1040 | "comment": "Spec target", 1041 | "match": "\\b(module|schema|struct|fun)", 1042 | "name": "storage.modifier.spec.target.move" 1043 | }, 1044 | { 1045 | "comment": "Spec define inline", 1046 | "match": "\\b(define)", 1047 | "name": "storage.modifier.spec.define.move" 1048 | }, 1049 | { 1050 | "comment": "Target name", 1051 | "match": "\\b(\\w+)\\b", 1052 | "name": "entity.name.function.move" 1053 | }, 1054 | { 1055 | "comment": "Spec block", 1056 | "begin": "{", 1057 | "end": "}", 1058 | "patterns": [ 1059 | { "include": "#comments" }, 1060 | { "include": "#spec_block" }, 1061 | { "include": "#spec_types" }, 1062 | { "include": "#spec_define" }, 1063 | { "include": "#spec_keywords" }, 1064 | { "include": "#control" }, 1065 | { "include": "#fun_call" }, 1066 | { "include": "#literals" }, 1067 | { "include": "#types" }, 1068 | { "include": "#let" } 1069 | ] 1070 | } 1071 | ] 1072 | } 1073 | }, 1074 | 1075 | "patterns": [ 1076 | { "include": "#address" }, 1077 | { "include": "#comments" }, 1078 | { "include": "#module" }, 1079 | { "include": "#script" }, 1080 | { "include": "#annotation" }, 1081 | { "include": "#comments" }, 1082 | { "include": "#annotation" }, 1083 | { "include": "#entry" }, 1084 | { "include": "#public-scope" }, 1085 | { "include": "#public" }, 1086 | { "include": "#native" }, 1087 | { "include": "#import" }, 1088 | { "include": "#friend" }, 1089 | { "include": "#const" }, 1090 | 1091 | { "include": "#struct" }, 1092 | { "include": "#has_ability" }, 1093 | 1094 | { "include": "#enum" }, 1095 | { "include": "#macro" }, 1096 | { "include": "#fun" }, 1097 | { "include": "#spec" } 1098 | ] 1099 | } 1100 | --------------------------------------------------------------------------------