├── .gitignore ├── DEVELOPMENT.md ├── Default.sublime-keymap ├── LICENSE ├── Preferences.sublime-settings ├── README.md ├── Support ├── Comments.tmPreferences ├── Default.sublime-commands ├── Indentation Rules.tmPreferences ├── Main.sublime-menu ├── Nim.sublime-build ├── Nim.sublime-completions └── Nim.sublime-settings └── Syntaxes ├── Nim CFG.sbnf ├── Nim CFG.sublime-syntax ├── Nim SCF.sublime-syntax ├── Nim.YAML-tmLanguage ├── Nim.sublime-syntax ├── Nim.tmLanguage ├── syntax_test.nim └── syntax_test.nim.cfg /.gitignore: -------------------------------------------------------------------------------- 1 | *.sublime-project 2 | *.sublime-workspace 3 | -------------------------------------------------------------------------------- /DEVELOPMENT.md: -------------------------------------------------------------------------------- 1 | NimLime Architecture Overview 2 | ============================= 3 | The following is a general overview of the NimLime plugin's design and the 4 | considerations that should be made when adding or extending functionality. 5 | 6 | 7 | Directory Structure 8 | ------------------- 9 | - **/Syntaxes** 10 | Sublime text syntax directory. 11 | Contains the Sublime Text syntax files used by NimLime. 12 | 13 | - **/Support** 14 | Main Sublime Text data directory. 15 | Contains menu, preferences, and other data files used by Sublime Text's 16 | plugin system. 17 | -------------------------------------------------------------------------------- /Default.sublime-keymap: -------------------------------------------------------------------------------- 1 | [ 2 | // Doc-comment completion 3 | { "keys": ["enter"], "command": "insert_snippet", "args": {"contents": "\n## $0"}, "context": 4 | [ 5 | { "key": "setting.doccontinue.enabled", "operand": true }, 6 | { "key": "preceding_text", "operand": "# *$", "operator": "not_regex_contains" }, 7 | { "key": "selector", "operand": "comment.line.documentation.nim" }, 8 | ] 9 | }, 10 | { "keys": ["enter"], "command": "insert_snippet", "args": {"contents": "\n## $0"}, "context": 11 | [ 12 | { "key": "setting.doccontinue.enabled", "operand": true }, 13 | { "key": "setting.doccontinue.autostop", "operand": false }, 14 | { "key": "selector", "operand": "comment.line.documentation.nim" }, 15 | ] 16 | }, 17 | 18 | // Multi-line doc-comment completion 19 | { "keys": ["["], "command": "insert_snippet", "args": {"contents": "[$0]##"}, "context": 20 | [ 21 | { "key": "selector", "operator":"equal", "operand": "comment.line.documentation.nim punctuation.definition.comment.nim"}, 22 | { "key": "preceding_text", "operator":"regex_contains", "operand": "##$"}, 23 | ] 24 | }, 25 | 26 | // Pragma completion 27 | { "keys": ["."], "command": "insert_snippet", "args": {"contents": ".$0."}, "context": 28 | [ 29 | { "key": "selector", "operand": "source.nim" }, 30 | { "key": "preceding_text", "operator": "regex_contains", "operand": "{$"}, 31 | { "key": "following_text", "operator": "regex_contains", "operand": "^}"} 32 | ] 33 | } 34 | ] -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 onionhammer (Erik O'Leary), Varriount (Clay Sweetser) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /Preferences.sublime-settings: -------------------------------------------------------------------------------- 1 | { 2 | // Continue doc-comment on the next line 3 | "doccontinue.enabled": true, 4 | // Stop doc-comment continuation after placing empty doc-comments 5 | "doccontinue.autostop": true, 6 | } 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Nim 2 | === 3 | 4 | The official Nim Programming Language plugin for Sublime Text. 5 | 6 | Features 7 | -------- 8 | 9 | * Syntax highlighting. 10 | * Snippets. 11 | * Automatic continuation of doc comments. 12 | 13 | Installation 14 | ------------ 15 | 16 | 1. Run `Package Control: Install Package` from the command palette. 17 | 2. Choose `Nim`. 18 | 19 | It is also recommended to install [LSP-nimlangserver](https://packagecontrol.io/packages/LSP-nimlangserver) 20 | to enjoy IDE-like features. 21 | 22 | Settings 23 | -------- 24 | 25 | See Preferences -> Package Settings -> Nim 26 | 27 | Contributing 28 | ------------ 29 | 30 | Pull requests are welcome! See DEVELOPMENT.md for an overview of Nim's design. 31 | 32 | Clone the repository in your Sublime package directory. 33 | 34 | Install the [PackageDev](https://github.com/SublimeText/PackageDev). 35 | 36 | Modify the `.YAML-tmLanguage` files and regenerate the `.tmLanguage` files 37 | by summoning the command palette and selecting the `Convert (YAML, JSON, PLIST) to...` 38 | command. Don't modify the `.tmLanguage` files, they will be overwritten! 39 | -------------------------------------------------------------------------------- /Support/Comments.tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | scope 6 | source.nim, source.nimcfg 7 | settings 8 | 9 | shellVariables 10 | 11 | 12 | name 13 | TM_COMMENT_START 14 | value 15 | # 16 | 17 | 18 | name 19 | TM_COMMENT_START_2 20 | value 21 | #[ 22 | 23 | 24 | name 25 | TM_COMMENT_END_2 26 | value 27 | ]# 28 | 29 | 30 | name 31 | TM_COMMENT_MODE_2 32 | value 33 | block 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /Support/Default.sublime-commands: -------------------------------------------------------------------------------- 1 | [ 2 | 3 | ] -------------------------------------------------------------------------------- /Support/Indentation Rules.tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | scope 6 | source.nim, source.nimcfg 7 | settings 8 | 9 | increaseIndentPattern 10 | ^.*(?:[:=]|\b(?:let|var|const|using|type|object|enum|tuple)) *$ 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Support/Main.sublime-menu: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "preferences", 4 | "children": 5 | [ 6 | { 7 | "id": "package-settings", 8 | "children": 9 | [ 10 | { 11 | "caption": "Nim", 12 | "children": 13 | [ 14 | { 15 | "command": "open_url", 16 | "args": { 17 | "url": "https://github.com/nim-lang/NimLime/issues" 18 | }, 19 | "caption": "Support/Issue Tracker" 20 | }, 21 | 22 | { "caption": "-" }, 23 | 24 | { 25 | "command": "edit_settings", "args": 26 | { 27 | "base_file": "${packages}/Nim/Preferences.sublime-settings", 28 | "default": "{\n\t$0\n}\n" 29 | }, 30 | "caption": "Settings" 31 | }, 32 | 33 | { 34 | "command": "edit_settings", "args": 35 | { 36 | "base_file": "${packages}/Nim/Default.sublime-keymap", 37 | "default": "[\n\t$0\n]\n" 38 | }, 39 | "caption": "Key Bindings" 40 | } 41 | ] 42 | } 43 | ] 44 | } 45 | ] 46 | } 47 | ] 48 | -------------------------------------------------------------------------------- /Support/Nim.sublime-build: -------------------------------------------------------------------------------- 1 | { 2 | "cmd": ["nim", "c", "$file"], 3 | "selector": "source.nim", 4 | "file_regex": "^(?:Error: [^:]*: )?(.+\\.\\w+)\\((\\d+)(?:, (\\d+))?\\) (.*)", 5 | 6 | "variants": [ 7 | { 8 | "cmd": ["nim", "c", "-r", "--verbosity:0", "--hints:off", "$file"], 9 | "name": "Run" 10 | }, 11 | { 12 | "cmd": ["nim", "c", "-r", "-d:danger", "--verbosity:0", "--hints:off", "$file"], 13 | "name": "Run: Danger" 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /Support/Nim.sublime-completions: -------------------------------------------------------------------------------- 1 | { 2 | "scope": "source.nim", 3 | 4 | "completions": [ 5 | { "trigger": "proc", "contents": "proc ${1:name}($2)$3 =\n\t" }, 6 | { "trigger": "func", "contents": "func ${1:name}($2)$3 =\n\t" }, 7 | { "trigger": "iterator", "contents": "iterator ${1:name}($2)$3 =\n\t" }, 8 | { "trigger": "template", "contents": "template ${1:name}($2)$3 =\n\t" }, 9 | { "trigger": "macro", "contents": "macro ${1:name}($2)$3 =\n\t" }, 10 | { "trigger": "converter", "contents": "converter ${1:name}($2)$3 =\n\t" }, 11 | { "trigger": "method", "contents": "method ${1:name}($2)$3 =\n\t" } 12 | ] 13 | } -------------------------------------------------------------------------------- /Support/Nim.sublime-settings: -------------------------------------------------------------------------------- 1 | { 2 | "tab_size": 2, 3 | "translate_tabs_to_spaces": true, 4 | } 5 | -------------------------------------------------------------------------------- /Syntaxes/Nim CFG.sbnf: -------------------------------------------------------------------------------- 1 | EXTENSIONS = 'nim.cfg' 2 | SCOPE = 'source.nimcfg' 3 | SCOPE_POSTFIX = `nimcfg` 4 | 5 | SYMBOL = '[A-Za-z]\w*' 6 | 7 | prototype: 8 | (~( block-comment | line-comment ))* 9 | ; 10 | 11 | main: 12 | (~( 13 | directives 14 | | assignements 15 | ))* 16 | ; 17 | 18 | line-comment{comment.line.number-sign}: 19 | '(#)(?: *(TODO|todo)\b)?'{ 20 | 1: punctuation.definition.comment, 21 | 2: invalid.deprecated 22 | } 23 | ~'$\n?' 24 | ; 25 | 26 | block-comment{comment.block}: 27 | `#[`{punctuation.definition.comment.begin} 28 | (~block-comment)* 29 | ~`]#`{punctuation.definition.comment.end} 30 | ; 31 | 32 | directives: 33 | if-stmt 34 | | env-stmt 35 | | write-stmt 36 | ; 37 | 38 | if-stmt: 39 | '(@) *(if\b)'{ 40 | 1: punctuation.definition.keyword, 41 | 2: keyword.control.conditional.if 42 | } 43 | bool-bin-expr `:`{punctuation.section.block.begin} 44 | block 45 | ; 46 | 47 | elif-stmt: 48 | '(@) *(elif\b)'{ 49 | 1: punctuation.definition.keyword, 50 | 2: keyword.control.conditional.elseif 51 | } 52 | bool-bin-expr `:`{punctuation.section.block.begin} 53 | ; 54 | 55 | else-stmt: 56 | '(@) *(else)(?: *(:))?'{ 57 | 1: punctuation.definition.keyword, 58 | 2: keyword.control.conditional.else, 59 | 3: punctuation.section.block.begin 60 | } 61 | ~(main)* 62 | ~'(?=@ *end\b)' 63 | ; 64 | 65 | bool-expr: 66 | language-constants 67 | | 'not\b'{keyword.operator.logical} bool-bin-expr 68 | | '(?:and|or)\b'{invalid.illegal} 69 | | SYMBOL 70 | | group 71 | ; 72 | 73 | bool-bin-expr: 74 | bool-expr ('(?:and|or)\b'{keyword.operator.logical} bool-bin-expr)? 75 | ; 76 | 77 | group{meta.group}: 78 | `(`{punctuation.section.group.begin} 79 | bool-bin-expr 80 | `)`{punctuation.section.group.end} 81 | ; 82 | 83 | block{meta.block}: 84 | (~( 85 | elif-stmt 86 | | else-stmt 87 | | main 88 | ))* 89 | ~'(@) *(end\b)'{ 90 | 1: punctuation.definition.keyword, 91 | 2: keyword.control.conditional.end 92 | } 93 | ; 94 | 95 | env-stmt: 96 | '(@) *((?:put|append|prepend)[Ee]nv\b)'{ 97 | 1: punctuation.definition.keyword, 98 | 2: keyword.other 99 | } 100 | (expr expr?)? 101 | ; 102 | 103 | write-stmt: 104 | '(@) *(write\b)'{ 105 | 1: punctuation.definition.keyword, 106 | 2: keyword.other 107 | } 108 | expr? 109 | ; 110 | 111 | assignements: 112 | '(--?)?#[SYMBOL]'{1: punctuation.definition.variable} 113 | (~'(\.)#[SYMBOL]'{1: punctuation.accessor.dot})* 114 | ~('(?:(\[)(#[SYMBOL])(]))? *(:|%?=)' { 115 | 1: punctuation.section.brackets.begin, 116 | 2: entity.other.attribute-name, 117 | 3: punctuation.section.brackets.end, 118 | 4: punctuation.separator.key-value 119 | } 120 | ( 121 | expr 122 | ( 123 | ( 124 | '[:=]'{punctuation.separator.key-value} 125 | | `&`{keyword.operator} 126 | ) 127 | concat-expr? 128 | )? 129 | )? 130 | | 131 | '(?=\S)' 132 | ) 133 | ; 134 | 135 | concat-expr: 136 | expr (`&`{keyword.operator} concat-expr)? 137 | ; 138 | 139 | expr: 140 | str-lits 141 | | numbers 142 | | language-constants 143 | | SYMBOL{string.unquoted} 144 | ; 145 | 146 | str-lits: 147 | triplestr-lit 148 | | rstr-lit 149 | | str-lit 150 | ; 151 | 152 | triplestr-lit: 153 | '([Rr])?(""")'{ 154 | 0: meta.string, 155 | 1: storage.type.string, 156 | 2: string.quoted.double.block punctuation.definition.string.begin 157 | } 158 | triplestr-lit-inner 159 | ; 160 | 161 | triplestr-lit-inner{meta.string string.quoted.double.block, include-prototype: false}: 162 | ~'"""(?!")'{punctuation.definition.string.end} 163 | ; 164 | 165 | rstr-lit: 166 | '([Rr])(")'{ 167 | 0: meta.string, 168 | 1: storage.type.string, 169 | 2: string.quoted.double punctuation.definition.string.begin 170 | } 171 | rstr-lit-inner 172 | ; 173 | 174 | rstr-lit-inner{meta.string string.quoted.double, include-prototype: false}: 175 | (~'""'{constant.character.escape})* 176 | ~( 177 | `"`{punctuation.definition.string.end} 178 | | '\n'{invalid.illegal} 179 | ) 180 | ; 181 | 182 | str-lit{meta.string string.quoted.double, include-prototype: false}: 183 | `"`{punctuation.definition.string.begin} 184 | (~( 185 | '\\(?:[ABCEFLNPRTVabceflnprtv"\'\\]|\d+|[Xx]\h{2}|[Uu](?:\h{4}|\{\h+}))'{constant.character.escape} 186 | | '\\'{invalid.illegal.lone-escape} 187 | ))* 188 | ~( 189 | `"`{punctuation.definition.string.end} 190 | | '\n'{invalid.illegal} 191 | ) 192 | ; 193 | 194 | numbers: 195 | '\b(0[Xx])(\h(?:_?\h)*)(\'?[Ii](?:8|16|32|64))?'{ 196 | 0: meta.number.integer.hexadecimal, 197 | 1: constant.numeric.base, 198 | 2: constant.numeric.value, 199 | 3: constant.numeric.suffix 200 | } 201 | | 202 | '\b(0o)([0-7](?:_?[0-7])*)(\'?[Ii](?:8|16|32|64))?'{ 203 | 0: meta.number.integer.octal, 204 | 1: constant.numeric.base, 205 | 2: constant.numeric.value, 206 | 3: constant.numeric.suffix 207 | } 208 | | 209 | '\b(0[Bb])([01](?:_?[01])*)(\'?[Ii](?:8|16|32|64))?'{ 210 | 0: meta.number.integer.binary, 211 | 1: constant.numeric.base, 212 | 2: constant.numeric.value, 213 | 3: constant.numeric.suffix 214 | } 215 | | 216 | '\b(\d(?:_?\d)*)(\'?[Ii](?:8|16|32|64))?'{ 217 | 0: meta.number.integer.decimal, 218 | 1: constant.numeric.value, 219 | 2: constant.numeric.suffix 220 | } 221 | ; 222 | 223 | language-constants: 224 | '(?:true|false|on|off)\b'{constant.language.boolean} 225 | ; 226 | -------------------------------------------------------------------------------- /Syntaxes/Nim CFG.sublime-syntax: -------------------------------------------------------------------------------- 1 | %YAML 1.2 2 | --- 3 | # http://www.sublimetext.com/docs/syntax.html 4 | version: 2 5 | name: Nim CFG 6 | file_extensions: 7 | - nim.cfg 8 | scope: source.nimcfg 9 | contexts: 10 | # Rule: assignements 11 | assignements|0: 12 | - match: '(\.)[A-Za-z]\w*' 13 | captures: 14 | 1: punctuation.accessor.dot.nimcfg 15 | - match: '(?:(\[)([A-Za-z]\w*)(]))? *(:|%?=)' 16 | captures: 17 | 1: punctuation.section.brackets.begin.nimcfg 18 | 2: entity.other.attribute-name.nimcfg 19 | 3: punctuation.section.brackets.end.nimcfg 20 | 4: punctuation.separator.key-value.nimcfg 21 | push: assignements|1 22 | pop: true 23 | - match: '(?=\S)' 24 | pop: true 25 | # Rule: assignements 26 | assignements|1: 27 | - match: '([Rr])?(""")' 28 | captures: 29 | 0: meta.string.nimcfg 30 | 1: storage.type.string.nimcfg 31 | 2: string.quoted.double.block.nimcfg punctuation.definition.string.begin.nimcfg 32 | push: [assignements|2, triplestr-lit-inner|0] 33 | pop: true 34 | - match: '([Rr])(")' 35 | captures: 36 | 0: meta.string.nimcfg 37 | 1: storage.type.string.nimcfg 38 | 2: string.quoted.double.nimcfg punctuation.definition.string.begin.nimcfg 39 | push: [assignements|2, rstr-lit-inner|0] 40 | pop: true 41 | - match: '"' 42 | scope: meta.string.nimcfg string.quoted.double.nimcfg punctuation.definition.string.begin.nimcfg 43 | push: [assignements|2, str-lit|0] 44 | pop: true 45 | - match: '\b(0[Xx])(\h(?:_?\h)*)(''?[Ii](?:8|16|32|64))?' 46 | captures: 47 | 0: meta.number.integer.hexadecimal.nimcfg 48 | 1: constant.numeric.base.nimcfg 49 | 2: constant.numeric.value.nimcfg 50 | 3: constant.numeric.suffix.nimcfg 51 | push: assignements|2 52 | pop: true 53 | - match: '\b(0o)([0-7](?:_?[0-7])*)(''?[Ii](?:8|16|32|64))?' 54 | captures: 55 | 0: meta.number.integer.octal.nimcfg 56 | 1: constant.numeric.base.nimcfg 57 | 2: constant.numeric.value.nimcfg 58 | 3: constant.numeric.suffix.nimcfg 59 | push: assignements|2 60 | pop: true 61 | - match: '\b(0[Bb])([01](?:_?[01])*)(''?[Ii](?:8|16|32|64))?' 62 | captures: 63 | 0: meta.number.integer.binary.nimcfg 64 | 1: constant.numeric.base.nimcfg 65 | 2: constant.numeric.value.nimcfg 66 | 3: constant.numeric.suffix.nimcfg 67 | push: assignements|2 68 | pop: true 69 | - match: '\b(\d(?:_?\d)*)(''?[Ii](?:8|16|32|64))?' 70 | captures: 71 | 0: meta.number.integer.decimal.nimcfg 72 | 1: constant.numeric.value.nimcfg 73 | 2: constant.numeric.suffix.nimcfg 74 | push: assignements|2 75 | pop: true 76 | - match: '(?:true|false|on|off)\b' 77 | scope: constant.language.boolean.nimcfg 78 | push: assignements|2 79 | pop: true 80 | - match: '[A-Za-z]\w*' 81 | scope: string.unquoted.nimcfg 82 | push: assignements|2 83 | pop: true 84 | - match: '(?=\S)' 85 | pop: true 86 | # Rule: assignements 87 | assignements|2: 88 | - match: '[:=]' 89 | scope: punctuation.separator.key-value.nimcfg 90 | push: concat-expr|0 91 | pop: true 92 | - match: '&' 93 | scope: keyword.operator.nimcfg 94 | push: concat-expr|0 95 | pop: true 96 | - match: '(?=\S)' 97 | pop: true 98 | # Rule: block-comment 99 | block-comment|0: 100 | - meta_content_scope: comment.block.nimcfg 101 | - match: '#\[' 102 | scope: comment.block.nimcfg punctuation.definition.comment.begin.nimcfg 103 | push: block-comment|0 104 | - match: '\]#' 105 | scope: comment.block.nimcfg punctuation.definition.comment.end.nimcfg 106 | pop: true 107 | # Rule: block 108 | block|0: 109 | - meta_content_scope: meta.block.nimcfg 110 | - match: '(@) *(elif\b)' 111 | captures: 112 | 1: punctuation.definition.keyword.nimcfg 113 | 2: keyword.control.conditional.elseif.nimcfg 114 | push: elif-stmt|0 115 | - match: '(@) *(else)(?: *(:))?' 116 | captures: 117 | 1: punctuation.definition.keyword.nimcfg 118 | 2: keyword.control.conditional.else.nimcfg 119 | 3: punctuation.section.block.begin.nimcfg 120 | push: else-stmt|0 121 | - match: '(@) *(if\b)' 122 | captures: 123 | 1: punctuation.definition.keyword.nimcfg 124 | 2: keyword.control.conditional.if.nimcfg 125 | push: if-stmt|0 126 | - match: '(@) *((?:put|append|prepend)[Ee]nv\b)' 127 | captures: 128 | 1: punctuation.definition.keyword.nimcfg 129 | 2: keyword.other.nimcfg 130 | push: env-stmt|0 131 | - match: '(@) *(write\b)' 132 | captures: 133 | 1: punctuation.definition.keyword.nimcfg 134 | 2: keyword.other.nimcfg 135 | push: expr|0 136 | - match: '(--?)?[A-Za-z]\w*' 137 | captures: 138 | 1: punctuation.definition.variable.nimcfg 139 | push: assignements|0 140 | - match: '(@) *(end\b)' 141 | scope: meta.block.nimcfg 142 | captures: 143 | 1: punctuation.definition.keyword.nimcfg 144 | 2: keyword.control.conditional.end.nimcfg 145 | pop: true 146 | # Rule: bool-bin-expr 147 | bool-bin-expr|0: 148 | - match: '(?:and|or)\b' 149 | scope: keyword.operator.logical.nimcfg 150 | push: bool-bin-expr|1 151 | pop: true 152 | - match: '(?=\S)' 153 | pop: true 154 | # Rule: bool-bin-expr 155 | bool-bin-expr|1: 156 | - match: '(?:true|false|on|off)\b' 157 | scope: constant.language.boolean.nimcfg 158 | push: bool-bin-expr|0 159 | pop: true 160 | - match: 'not\b' 161 | scope: keyword.operator.logical.nimcfg 162 | push: [bool-bin-expr|0, bool-bin-expr|1] 163 | pop: true 164 | - match: '(?:and|or)\b' 165 | scope: invalid.illegal.nimcfg 166 | push: bool-bin-expr|0 167 | pop: true 168 | - match: '[A-Za-z]\w*' 169 | push: bool-bin-expr|0 170 | pop: true 171 | - match: '\(' 172 | scope: meta.group.nimcfg punctuation.section.group.begin.nimcfg 173 | push: [bool-bin-expr|0, group|0] 174 | pop: true 175 | - match: '\S' 176 | scope: invalid.illegal.nimcfg 177 | pop: true 178 | # Rule: concat-expr 179 | concat-expr|0: 180 | - match: '([Rr])?(""")' 181 | captures: 182 | 0: meta.string.nimcfg 183 | 1: storage.type.string.nimcfg 184 | 2: string.quoted.double.block.nimcfg punctuation.definition.string.begin.nimcfg 185 | push: [concat-expr|1, triplestr-lit-inner|0] 186 | pop: true 187 | - match: '([Rr])(")' 188 | captures: 189 | 0: meta.string.nimcfg 190 | 1: storage.type.string.nimcfg 191 | 2: string.quoted.double.nimcfg punctuation.definition.string.begin.nimcfg 192 | push: [concat-expr|1, rstr-lit-inner|0] 193 | pop: true 194 | - match: '"' 195 | scope: meta.string.nimcfg string.quoted.double.nimcfg punctuation.definition.string.begin.nimcfg 196 | push: [concat-expr|1, str-lit|0] 197 | pop: true 198 | - match: '\b(0[Xx])(\h(?:_?\h)*)(''?[Ii](?:8|16|32|64))?' 199 | captures: 200 | 0: meta.number.integer.hexadecimal.nimcfg 201 | 1: constant.numeric.base.nimcfg 202 | 2: constant.numeric.value.nimcfg 203 | 3: constant.numeric.suffix.nimcfg 204 | push: concat-expr|1 205 | pop: true 206 | - match: '\b(0o)([0-7](?:_?[0-7])*)(''?[Ii](?:8|16|32|64))?' 207 | captures: 208 | 0: meta.number.integer.octal.nimcfg 209 | 1: constant.numeric.base.nimcfg 210 | 2: constant.numeric.value.nimcfg 211 | 3: constant.numeric.suffix.nimcfg 212 | push: concat-expr|1 213 | pop: true 214 | - match: '\b(0[Bb])([01](?:_?[01])*)(''?[Ii](?:8|16|32|64))?' 215 | captures: 216 | 0: meta.number.integer.binary.nimcfg 217 | 1: constant.numeric.base.nimcfg 218 | 2: constant.numeric.value.nimcfg 219 | 3: constant.numeric.suffix.nimcfg 220 | push: concat-expr|1 221 | pop: true 222 | - match: '\b(\d(?:_?\d)*)(''?[Ii](?:8|16|32|64))?' 223 | captures: 224 | 0: meta.number.integer.decimal.nimcfg 225 | 1: constant.numeric.value.nimcfg 226 | 2: constant.numeric.suffix.nimcfg 227 | push: concat-expr|1 228 | pop: true 229 | - match: '(?:true|false|on|off)\b' 230 | scope: constant.language.boolean.nimcfg 231 | push: concat-expr|1 232 | pop: true 233 | - match: '[A-Za-z]\w*' 234 | scope: string.unquoted.nimcfg 235 | push: concat-expr|1 236 | pop: true 237 | - match: '(?=\S)' 238 | pop: true 239 | # Rule: concat-expr 240 | concat-expr|1: 241 | - match: '&' 242 | scope: keyword.operator.nimcfg 243 | push: concat-expr|2 244 | pop: true 245 | - match: '(?=\S)' 246 | pop: true 247 | # Rule: concat-expr 248 | concat-expr|2: 249 | - match: '([Rr])?(""")' 250 | captures: 251 | 0: meta.string.nimcfg 252 | 1: storage.type.string.nimcfg 253 | 2: string.quoted.double.block.nimcfg punctuation.definition.string.begin.nimcfg 254 | push: [concat-expr|1, triplestr-lit-inner|0] 255 | pop: true 256 | - match: '([Rr])(")' 257 | captures: 258 | 0: meta.string.nimcfg 259 | 1: storage.type.string.nimcfg 260 | 2: string.quoted.double.nimcfg punctuation.definition.string.begin.nimcfg 261 | push: [concat-expr|1, rstr-lit-inner|0] 262 | pop: true 263 | - match: '"' 264 | scope: meta.string.nimcfg string.quoted.double.nimcfg punctuation.definition.string.begin.nimcfg 265 | push: [concat-expr|1, str-lit|0] 266 | pop: true 267 | - match: '\b(0[Xx])(\h(?:_?\h)*)(''?[Ii](?:8|16|32|64))?' 268 | captures: 269 | 0: meta.number.integer.hexadecimal.nimcfg 270 | 1: constant.numeric.base.nimcfg 271 | 2: constant.numeric.value.nimcfg 272 | 3: constant.numeric.suffix.nimcfg 273 | push: concat-expr|1 274 | pop: true 275 | - match: '\b(0o)([0-7](?:_?[0-7])*)(''?[Ii](?:8|16|32|64))?' 276 | captures: 277 | 0: meta.number.integer.octal.nimcfg 278 | 1: constant.numeric.base.nimcfg 279 | 2: constant.numeric.value.nimcfg 280 | 3: constant.numeric.suffix.nimcfg 281 | push: concat-expr|1 282 | pop: true 283 | - match: '\b(0[Bb])([01](?:_?[01])*)(''?[Ii](?:8|16|32|64))?' 284 | captures: 285 | 0: meta.number.integer.binary.nimcfg 286 | 1: constant.numeric.base.nimcfg 287 | 2: constant.numeric.value.nimcfg 288 | 3: constant.numeric.suffix.nimcfg 289 | push: concat-expr|1 290 | pop: true 291 | - match: '\b(\d(?:_?\d)*)(''?[Ii](?:8|16|32|64))?' 292 | captures: 293 | 0: meta.number.integer.decimal.nimcfg 294 | 1: constant.numeric.value.nimcfg 295 | 2: constant.numeric.suffix.nimcfg 296 | push: concat-expr|1 297 | pop: true 298 | - match: '(?:true|false|on|off)\b' 299 | scope: constant.language.boolean.nimcfg 300 | push: concat-expr|1 301 | pop: true 302 | - match: '[A-Za-z]\w*' 303 | scope: string.unquoted.nimcfg 304 | push: concat-expr|1 305 | pop: true 306 | - match: '\S' 307 | scope: invalid.illegal.nimcfg 308 | pop: true 309 | # Rule: elif-stmt 310 | elif-stmt|0: 311 | - match: '(?:true|false|on|off)\b' 312 | scope: constant.language.boolean.nimcfg 313 | push: [elif-stmt|1, bool-bin-expr|0] 314 | pop: true 315 | - match: 'not\b' 316 | scope: keyword.operator.logical.nimcfg 317 | push: [elif-stmt|1, bool-bin-expr|0, bool-bin-expr|1] 318 | pop: true 319 | - match: '(?:and|or)\b' 320 | scope: invalid.illegal.nimcfg 321 | push: [elif-stmt|1, bool-bin-expr|0] 322 | pop: true 323 | - match: '[A-Za-z]\w*' 324 | push: [elif-stmt|1, bool-bin-expr|0] 325 | pop: true 326 | - match: '\(' 327 | scope: meta.group.nimcfg punctuation.section.group.begin.nimcfg 328 | push: [elif-stmt|1, bool-bin-expr|0, group|0] 329 | pop: true 330 | - match: '\S' 331 | scope: invalid.illegal.nimcfg 332 | pop: true 333 | # Rule: elif-stmt 334 | elif-stmt|1: 335 | - match: ':' 336 | scope: punctuation.section.block.begin.nimcfg 337 | pop: true 338 | - match: '\S' 339 | scope: invalid.illegal.nimcfg 340 | pop: true 341 | # Rule: else-stmt 342 | else-stmt|0: 343 | - match: '(@) *(if\b)' 344 | captures: 345 | 1: punctuation.definition.keyword.nimcfg 346 | 2: keyword.control.conditional.if.nimcfg 347 | push: if-stmt|0 348 | - match: '(@) *((?:put|append|prepend)[Ee]nv\b)' 349 | captures: 350 | 1: punctuation.definition.keyword.nimcfg 351 | 2: keyword.other.nimcfg 352 | push: env-stmt|0 353 | - match: '(@) *(write\b)' 354 | captures: 355 | 1: punctuation.definition.keyword.nimcfg 356 | 2: keyword.other.nimcfg 357 | push: expr|0 358 | - match: '(--?)?[A-Za-z]\w*' 359 | captures: 360 | 1: punctuation.definition.variable.nimcfg 361 | push: assignements|0 362 | - match: '(?=@ *end\b)' 363 | pop: true 364 | # Rule: env-stmt 365 | env-stmt|0: 366 | - match: '([Rr])?(""")' 367 | captures: 368 | 0: meta.string.nimcfg 369 | 1: storage.type.string.nimcfg 370 | 2: string.quoted.double.block.nimcfg punctuation.definition.string.begin.nimcfg 371 | push: [expr|0, triplestr-lit-inner|0] 372 | pop: true 373 | - match: '([Rr])(")' 374 | captures: 375 | 0: meta.string.nimcfg 376 | 1: storage.type.string.nimcfg 377 | 2: string.quoted.double.nimcfg punctuation.definition.string.begin.nimcfg 378 | push: [expr|0, rstr-lit-inner|0] 379 | pop: true 380 | - match: '"' 381 | scope: meta.string.nimcfg string.quoted.double.nimcfg punctuation.definition.string.begin.nimcfg 382 | push: [expr|0, str-lit|0] 383 | pop: true 384 | - match: '\b(0[Xx])(\h(?:_?\h)*)(''?[Ii](?:8|16|32|64))?' 385 | captures: 386 | 0: meta.number.integer.hexadecimal.nimcfg 387 | 1: constant.numeric.base.nimcfg 388 | 2: constant.numeric.value.nimcfg 389 | 3: constant.numeric.suffix.nimcfg 390 | push: expr|0 391 | pop: true 392 | - match: '\b(0o)([0-7](?:_?[0-7])*)(''?[Ii](?:8|16|32|64))?' 393 | captures: 394 | 0: meta.number.integer.octal.nimcfg 395 | 1: constant.numeric.base.nimcfg 396 | 2: constant.numeric.value.nimcfg 397 | 3: constant.numeric.suffix.nimcfg 398 | push: expr|0 399 | pop: true 400 | - match: '\b(0[Bb])([01](?:_?[01])*)(''?[Ii](?:8|16|32|64))?' 401 | captures: 402 | 0: meta.number.integer.binary.nimcfg 403 | 1: constant.numeric.base.nimcfg 404 | 2: constant.numeric.value.nimcfg 405 | 3: constant.numeric.suffix.nimcfg 406 | push: expr|0 407 | pop: true 408 | - match: '\b(\d(?:_?\d)*)(''?[Ii](?:8|16|32|64))?' 409 | captures: 410 | 0: meta.number.integer.decimal.nimcfg 411 | 1: constant.numeric.value.nimcfg 412 | 2: constant.numeric.suffix.nimcfg 413 | push: expr|0 414 | pop: true 415 | - match: '(?:true|false|on|off)\b' 416 | scope: constant.language.boolean.nimcfg 417 | push: expr|0 418 | pop: true 419 | - match: '[A-Za-z]\w*' 420 | scope: string.unquoted.nimcfg 421 | push: expr|0 422 | pop: true 423 | - match: '(?=\S)' 424 | pop: true 425 | # Rule: expr 426 | expr|0: 427 | - match: '([Rr])?(""")' 428 | captures: 429 | 0: meta.string.nimcfg 430 | 1: storage.type.string.nimcfg 431 | 2: string.quoted.double.block.nimcfg punctuation.definition.string.begin.nimcfg 432 | push: triplestr-lit-inner|0 433 | pop: true 434 | - match: '([Rr])(")' 435 | captures: 436 | 0: meta.string.nimcfg 437 | 1: storage.type.string.nimcfg 438 | 2: string.quoted.double.nimcfg punctuation.definition.string.begin.nimcfg 439 | push: rstr-lit-inner|0 440 | pop: true 441 | - match: '"' 442 | scope: meta.string.nimcfg string.quoted.double.nimcfg punctuation.definition.string.begin.nimcfg 443 | push: str-lit|0 444 | pop: true 445 | - match: '\b(0[Xx])(\h(?:_?\h)*)(''?[Ii](?:8|16|32|64))?' 446 | captures: 447 | 0: meta.number.integer.hexadecimal.nimcfg 448 | 1: constant.numeric.base.nimcfg 449 | 2: constant.numeric.value.nimcfg 450 | 3: constant.numeric.suffix.nimcfg 451 | pop: true 452 | - match: '\b(0o)([0-7](?:_?[0-7])*)(''?[Ii](?:8|16|32|64))?' 453 | captures: 454 | 0: meta.number.integer.octal.nimcfg 455 | 1: constant.numeric.base.nimcfg 456 | 2: constant.numeric.value.nimcfg 457 | 3: constant.numeric.suffix.nimcfg 458 | pop: true 459 | - match: '\b(0[Bb])([01](?:_?[01])*)(''?[Ii](?:8|16|32|64))?' 460 | captures: 461 | 0: meta.number.integer.binary.nimcfg 462 | 1: constant.numeric.base.nimcfg 463 | 2: constant.numeric.value.nimcfg 464 | 3: constant.numeric.suffix.nimcfg 465 | pop: true 466 | - match: '\b(\d(?:_?\d)*)(''?[Ii](?:8|16|32|64))?' 467 | captures: 468 | 0: meta.number.integer.decimal.nimcfg 469 | 1: constant.numeric.value.nimcfg 470 | 2: constant.numeric.suffix.nimcfg 471 | pop: true 472 | - match: '(?:true|false|on|off)\b' 473 | scope: constant.language.boolean.nimcfg 474 | pop: true 475 | - match: '[A-Za-z]\w*' 476 | scope: string.unquoted.nimcfg 477 | pop: true 478 | - match: '(?=\S)' 479 | pop: true 480 | # Rule: group 481 | group|0: 482 | - meta_content_scope: meta.group.nimcfg 483 | - match: '(?:true|false|on|off)\b' 484 | scope: constant.language.boolean.nimcfg 485 | push: [group|1, bool-bin-expr|0] 486 | pop: true 487 | - match: 'not\b' 488 | scope: keyword.operator.logical.nimcfg 489 | push: [group|1, bool-bin-expr|0, bool-bin-expr|1] 490 | pop: true 491 | - match: '(?:and|or)\b' 492 | scope: invalid.illegal.nimcfg 493 | push: [group|1, bool-bin-expr|0] 494 | pop: true 495 | - match: '[A-Za-z]\w*' 496 | push: [group|1, bool-bin-expr|0] 497 | pop: true 498 | - match: '\(' 499 | scope: meta.group.nimcfg punctuation.section.group.begin.nimcfg 500 | push: [group|1, bool-bin-expr|0, group|0] 501 | pop: true 502 | - match: '\S' 503 | scope: invalid.illegal.nimcfg 504 | pop: true 505 | # Rule: group 506 | group|1: 507 | - meta_content_scope: meta.group.nimcfg 508 | - match: '\)' 509 | scope: meta.group.nimcfg punctuation.section.group.end.nimcfg 510 | pop: true 511 | - match: '\S' 512 | scope: invalid.illegal.nimcfg 513 | pop: true 514 | # Rule: if-stmt 515 | if-stmt|0: 516 | - match: '(?:true|false|on|off)\b' 517 | scope: constant.language.boolean.nimcfg 518 | push: [if-stmt|1, bool-bin-expr|0] 519 | pop: true 520 | - match: 'not\b' 521 | scope: keyword.operator.logical.nimcfg 522 | push: [if-stmt|1, bool-bin-expr|0, bool-bin-expr|1] 523 | pop: true 524 | - match: '(?:and|or)\b' 525 | scope: invalid.illegal.nimcfg 526 | push: [if-stmt|1, bool-bin-expr|0] 527 | pop: true 528 | - match: '[A-Za-z]\w*' 529 | push: [if-stmt|1, bool-bin-expr|0] 530 | pop: true 531 | - match: '\(' 532 | scope: meta.group.nimcfg punctuation.section.group.begin.nimcfg 533 | push: [if-stmt|1, bool-bin-expr|0, group|0] 534 | pop: true 535 | - match: '\S' 536 | scope: invalid.illegal.nimcfg 537 | pop: true 538 | # Rule: if-stmt 539 | if-stmt|1: 540 | - match: ':' 541 | scope: punctuation.section.block.begin.nimcfg 542 | push: block|0 543 | pop: true 544 | - match: '\S' 545 | scope: invalid.illegal.nimcfg 546 | pop: true 547 | # Rule: line-comment 548 | line-comment|0: 549 | - meta_content_scope: comment.line.number-sign.nimcfg 550 | - match: '$\n?' 551 | scope: comment.line.number-sign.nimcfg 552 | pop: true 553 | # Rule: main 554 | main: 555 | - match: '(@) *(if\b)' 556 | captures: 557 | 1: punctuation.definition.keyword.nimcfg 558 | 2: keyword.control.conditional.if.nimcfg 559 | push: if-stmt|0 560 | - match: '(@) *((?:put|append|prepend)[Ee]nv\b)' 561 | captures: 562 | 1: punctuation.definition.keyword.nimcfg 563 | 2: keyword.other.nimcfg 564 | push: env-stmt|0 565 | - match: '(@) *(write\b)' 566 | captures: 567 | 1: punctuation.definition.keyword.nimcfg 568 | 2: keyword.other.nimcfg 569 | push: expr|0 570 | - match: '(--?)?[A-Za-z]\w*' 571 | captures: 572 | 1: punctuation.definition.variable.nimcfg 573 | push: assignements|0 574 | # Rule: prototype 575 | prototype: 576 | - match: '#\[' 577 | scope: comment.block.nimcfg punctuation.definition.comment.begin.nimcfg 578 | push: block-comment|0 579 | - match: '(#)(?: *(TODO|todo)\b)?' 580 | scope: comment.line.number-sign.nimcfg 581 | captures: 582 | 1: punctuation.definition.comment.nimcfg 583 | 2: invalid.deprecated.nimcfg 584 | push: line-comment|0 585 | # Rule: rstr-lit-inner 586 | rstr-lit-inner|0: 587 | - meta_content_scope: meta.string.nimcfg string.quoted.double.nimcfg 588 | - meta_include_prototype: false 589 | - match: '""' 590 | scope: constant.character.escape.nimcfg 591 | - match: '"' 592 | scope: meta.string.nimcfg string.quoted.double.nimcfg punctuation.definition.string.end.nimcfg 593 | pop: true 594 | - match: '\n' 595 | scope: meta.string.nimcfg string.quoted.double.nimcfg invalid.illegal.nimcfg 596 | pop: true 597 | # Rule: str-lit 598 | str-lit|0: 599 | - meta_content_scope: meta.string.nimcfg string.quoted.double.nimcfg 600 | - meta_include_prototype: false 601 | - match: '\\(?:[ABCEFLNPRTVabceflnprtv"''\\]|\d+|[Xx]\h{2}|[Uu](?:\h{4}|\{\h+}))' 602 | scope: constant.character.escape.nimcfg 603 | - match: '\\' 604 | scope: invalid.illegal.lone-escape.nimcfg 605 | - match: '"' 606 | scope: meta.string.nimcfg string.quoted.double.nimcfg punctuation.definition.string.end.nimcfg 607 | pop: true 608 | - match: '\n' 609 | scope: meta.string.nimcfg string.quoted.double.nimcfg invalid.illegal.nimcfg 610 | pop: true 611 | # Rule: triplestr-lit-inner 612 | triplestr-lit-inner|0: 613 | - meta_content_scope: meta.string.nimcfg string.quoted.double.block.nimcfg 614 | - meta_include_prototype: false 615 | - match: '"""(?!")' 616 | scope: meta.string.nimcfg string.quoted.double.block.nimcfg punctuation.definition.string.end.nimcfg 617 | pop: true 618 | -------------------------------------------------------------------------------- /Syntaxes/Nim SCF.sublime-syntax: -------------------------------------------------------------------------------- 1 | %YAML 1.2 2 | --- 3 | version: 2 4 | name: Nim Source Code Filter 5 | scope: source.nimscf 6 | file_extensions: [nimf] 7 | 8 | contexts: 9 | main: 10 | - match: '^ *#' 11 | push: 12 | - match: '(end) (proc|func|method|template|macro|iterator|converter)\b' 13 | captures: 14 | 1: keyword.control.flow.nimscf 15 | 2: keyword.declaration.function.nimscf 16 | - include: scope:source.nim 17 | with_prototype: 18 | - match: '^ *#' 19 | - match: ^(?! *#) 20 | pop: true 21 | -------------------------------------------------------------------------------- /Syntaxes/Nim.YAML-tmLanguage: -------------------------------------------------------------------------------- 1 | # [PackageDev] target_format: plist, ext: tmLanguage 2 | --- 3 | name: Nim 4 | scopeName: source.nim 5 | fileTypes: [nim, nims, nimble] 6 | 7 | 8 | patterns: 9 | - include: '#pragmas' 10 | - include: '#brackets' 11 | - include: '#punctuations' 12 | - include: '#block-doc-comments' 13 | - include: '#comments' 14 | - include: '#for-stmts' 15 | - include: '#asm-stmts' 16 | - include: '#routines' 17 | - include: '#fmt-strs' 18 | - include: '#operators' 19 | - include: '#literals' 20 | - include: '#keywords' 21 | - include: '#do-stmts' 22 | - include: '#calls' 23 | - include: '#types' 24 | - include: '#builtins' 25 | - include: '#generic-symbols' 26 | 27 | repository: 28 | doc-comments: 29 | patterns: 30 | - include: '#block-doc-comments' 31 | - include: '#line-doc-comments' 32 | 33 | block-doc-comments: 34 | patterns: 35 | - begin: '##\[' 36 | beginCaptures: 37 | '0': {name: punctuation.definition.comment.begin.nim} 38 | end: ']##' 39 | endCaptures: 40 | '0': {name: punctuation.definition.comment.end.nim} 41 | name: comment.block.documentation.nim 42 | patterns: 43 | - include: '#block-doc-comments' 44 | 45 | line-doc-comments: 46 | patterns: 47 | - begin: '##' 48 | beginCaptures: 49 | '0': {name: punctuation.definition.comment.nim} 50 | end: '$\n?' 51 | name: comment.line.documentation.nim 52 | 53 | comments: 54 | patterns: 55 | - include: '#block-comments' 56 | - include: '#line-comments' 57 | 58 | block-comments: 59 | patterns: 60 | - begin: '#\[' 61 | beginCaptures: 62 | '0': {name: punctuation.definition.comment.begin.nim} 63 | end: ']#' 64 | endCaptures: 65 | '0': {name: punctuation.definition.comment.end.nim} 66 | name: comment.block.number-sign.nim 67 | patterns: 68 | - include: '#block-comments' 69 | 70 | line-comments: 71 | patterns: 72 | - begin: '(#)(?: *(TODO|todo)\b)?' 73 | beginCaptures: 74 | '1': {name: punctuation.definition.comment.nim} 75 | '2': {name: invalid.deprecated.nim} 76 | end: '$\n?' 77 | name: comment.line.number-sign.nim 78 | 79 | brackets: 80 | patterns: 81 | - include: '#square-brackets' 82 | - begin: '\{' 83 | beginCaptures: 84 | '0': {name: punctuation.section.braces.begin.nim} 85 | end: '}' 86 | endCaptures: 87 | '0': {name: punctuation.section.braces.end.nim} 88 | name: meta.braces.nim 89 | patterns: 90 | - include: '$self' 91 | 92 | - begin: '\(' 93 | beginCaptures: 94 | '0': {name: punctuation.section.parens.begin.nim} 95 | end: '\)' 96 | endCaptures: 97 | '0': {name: punctuation.section.parens.end.nim} 98 | name: meta.parens.nim 99 | patterns: 100 | - include: '$self' 101 | 102 | square-brackets: 103 | patterns: 104 | - begin: '\[' 105 | beginCaptures: 106 | '0': {name: punctuation.section.brackets.begin.nim} 107 | end: ']' 108 | endCaptures: 109 | '0': {name: punctuation.section.brackets.end.nim} 110 | name: meta.brackets.nim 111 | patterns: 112 | - include: '$self' 113 | 114 | punctuations: 115 | patterns: 116 | - match: ';' 117 | name: punctuation.terminator.statement.nim 118 | - match: ',' 119 | name: punctuation.separator.nim 120 | - match: ':' 121 | name: punctuation.section.block.begin.nim 122 | - match: '\.(?![-=+*/<>@$~&%|!?^.:\\∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔])' 123 | name: punctuation.accessor.dot.nim 124 | - match: '(\*) *(:|(?=,|#|\{\.))' 125 | captures: 126 | '1': {name: storage.modifier.nim} 127 | '2': {name: punctuation.separator.annotation.nim} 128 | - match: '\)|]|}' 129 | name: invalid.illegal.nim 130 | 131 | for-stmts: 132 | patterns: 133 | - begin: for\b 134 | beginCaptures: 135 | '0': {name: keyword.control.loop.for.nim} 136 | end: (in\b)|(?=[^#,{_`A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]\s]) 137 | endCaptures: 138 | '1': {name: keyword.control.loop.for.in.nim} 139 | patterns: 140 | - begin: \( 141 | beginCaptures: 142 | '0': {name: punctuation.section.parens.begin.nim} 143 | end: '(in\b)|(\))|(?=[^#,{_`A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]\s])' 144 | endCaptures: 145 | '1': {name: keyword.control.loop.for.in.nim} 146 | '2': {name: punctuation.section.parens.end.nim} 147 | patterns: 148 | - include: '#for-stmt-1' 149 | - include: '#for-stmt-1' 150 | 151 | for-stmt-1: 152 | patterns: 153 | - match: ',' 154 | name: punctuation.separator.nim 155 | - match: '[A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])*|_|`[^;,\n`]+`' 156 | - include: '#pragmas' 157 | - include: '#comments' 158 | 159 | asm-stmts: 160 | patterns: 161 | - begin: asm\b 162 | beginCaptures: 163 | '0': {name: keyword.control.flow.nim} 164 | end: '(?=[^"Rr{\s])|(?<=")' 165 | patterns: 166 | - include: '#pragmas' 167 | - include: '#asm-stmt-1' 168 | 169 | asm-stmt-1: 170 | patterns: 171 | - begin: '([Rr])?(""")' 172 | captures: 173 | '1': {name: storage.type.string.nim} 174 | '2': {name: string.quoted.triple.nim punctuation.definition.string.begin.nim} 175 | end: '"""(?!")' 176 | endCaptures: 177 | '0': {name: string.quoted.triple.nim punctuation.definition.string.end.nim} 178 | contentName: string.quoted.triple.nim 179 | patterns: 180 | - include: '#interpolation' 181 | - begin: '([Rr])(")' 182 | beginCaptures: 183 | '1': {name: storage.type.string.nim} 184 | '2': {name: string.quoted.double.nim punctuation.definition.string.begin.nim} 185 | end: (")|(\n) 186 | endCaptures: 187 | '1': {name: string.quoted.double.nim punctuation.definition.string.begin.nim} 188 | '2': {name: invalid.illegal.nim} 189 | contentName: string.quoted.double.nim 190 | patterns: 191 | - include: '#interpolation' 192 | - begin: '"' 193 | beginCaptures: 194 | '0': {name: punctuation.definition.string.begin.nim} 195 | end: (")|(\n) 196 | endCaptures: 197 | '1': {name: string.quoted.double.nim punctuation.definition.string.begin.nim} 198 | '2': {name: invalid.illegal.nim} 199 | name: string.quoted.double.nim 200 | patterns: 201 | - match: '\\(?:[ABCEFLNPRTVabceflnprtv"''\\]|\d+|[Xx]\h{2}|[Uu](?:\h{4}|\{\h+}))' 202 | name: constant.character.escape.nim 203 | - match: \\ 204 | name: invalid.illegal.lone-escape.nim 205 | - include: '#interpolation' 206 | 207 | interpolation: 208 | patterns: 209 | - match: '(`) *(?:[A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])*|_) *(`)' 210 | captures: 211 | '0': {name: source.nim.embedded} 212 | '1': {name: punctuation.section.embedded.begin.nim} 213 | '2': {name: punctuation.section.embedded.end.nim} 214 | 215 | routines: 216 | patterns: 217 | - begin: '(?x: 218 | (proc|template|iterator|func|method|macro|converter)\b 219 | (?:[ ]*([A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])*|_|`[^;,\n`]+`)(?:[ ]*(\*))?)? 220 | )' 221 | beginCaptures: 222 | '1': {name: storage.type.function.nim} 223 | '2': {name: entity.name.function.nim} 224 | '3': {name: storage.modifier.nim} 225 | end: (:)|(?=[^#\(\[:\s]|##) 226 | endCaptures: 227 | '1': {name: punctuation.separator.annotation.nim} 228 | name: meta.function.nim 229 | patterns: 230 | - include: '#comments' 231 | - include: '#patterns' 232 | - include: '#generic-param-list' 233 | - include: '#param-list' 234 | 235 | patterns: 236 | patterns: 237 | - begin: '\{(?!\.)' 238 | beginCaptures: 239 | '0': {name: punctuation.section.pattern.begin.nim} 240 | end: '}' 241 | endCaptures: 242 | '0': {name: punctuation.section.pattern.end.nim} 243 | name: meta.pattern.nim 244 | patterns: 245 | - include: $self 246 | 247 | param-list: 248 | patterns: 249 | - begin: '\(' 250 | beginCaptures: 251 | '0': {name: punctuation.section.parameters.begin.nim} 252 | end: '\)' 253 | endCaptures: 254 | '0': {name: punctuation.section.parameters.end.nim} 255 | name: meta.function.parameters 256 | patterns: 257 | - match: '[,;]' 258 | name: punctuation.separator.nim 259 | - begin: '(:)|(=)' 260 | beginCaptures: 261 | '1': {name: punctuation.separator.annotation.nim} 262 | '2': {name: keyword.operator.assignment.nim} 263 | end: (?=[,;\)]) 264 | patterns: 265 | - include: $self 266 | - include: '#comments' 267 | 268 | fmt-strs: 269 | patterns: 270 | - begin: '(?:(fmt)|(&))(""")' 271 | beginCaptures: 272 | '1': {name: meta.function-call.nim variable.function.nim} 273 | '2': {name: keyword.operator.nim} 274 | '3': {name: string.quoted.triple.nim punctuation.definition.string.begin.nim} 275 | end: '"""(?!")' 276 | endCaptures: 277 | '0': {name: string.quoted.triple.nim punctuation.definition.string.end.nim} 278 | contentName: string.quoted.triple.nim 279 | patterns: 280 | - match: '{{|}}' 281 | name: constant.character.escape.nim 282 | - begin: '{' 283 | beginCaptures: 284 | '0': {name: punctuation.section.embedded.begin.nim} 285 | end: '(=?(?: *:[^}]*)?) *(})|(?="""[^"])' 286 | endCaptures: 287 | '1': {name: constant.other.format-spec.nim} 288 | '2': {name: punctuation.section.embedded.end.nim} 289 | name: source.nim 290 | patterns: 291 | - include: $self 292 | - begin: (fmt)(") 293 | beginCaptures: 294 | '1': {name: meta.function-call.nim variable.function.nim} 295 | '2': {name: string.quoted.double.nim punctuation.definition.string.begin.nim} 296 | end: ("(?!"))|(\n) 297 | endCaptures: 298 | '1': {name: string.quoted.double.nim punctuation.definition.string.end.nim} 299 | '2': {name: invalid.illegal.nim} 300 | contentName: string.quoted.triple.nim 301 | patterns: 302 | - match: '{{|}}|""' 303 | name: constant.character.escape.nim 304 | - begin: '{' 305 | beginCaptures: 306 | '0': {name: punctuation.section.embedded.begin.nim} 307 | end: '(=?(?: *:[^}]*)?) *(})|(\n)|(?=")' 308 | endCaptures: 309 | '1': {name: constant.other.format-spec.nim} 310 | '2': {name: punctuation.section.embedded.end.nim} 311 | '3': {name: invalid.illegal.nim} 312 | name: source.nim 313 | patterns: 314 | - include: $self 315 | - begin: (&)(") 316 | beginCaptures: 317 | '1': {name: keyword.operator.nim} 318 | '2': {name: string.quoted.double.nim punctuation.definition.string.begin.nim} 319 | end: (")|(\n) 320 | endCaptures: 321 | '1': {name: string.quoted.double.nim punctuation.definition.string.end.nim} 322 | '2': {name: invalid.illegal.nim} 323 | contentName: string.quoted.double.nim 324 | patterns: 325 | - match: '{{|}}' 326 | name: constant.character.escape.nim 327 | - begin: '{' 328 | beginCaptures: 329 | '0': {name: punctuation.section.embedded.begin.nim} 330 | end: '(=?(?: *:[^}]*)?) *(})|(\n)|(?=")' 331 | endCaptures: 332 | '1': {name: constant.other.format-spec.nim} 333 | '2': {name: punctuation.section.embedded.end.nim} 334 | '3': {name: invalid.illegal.nim} 335 | name: source.nim 336 | patterns: 337 | - match: '\\(?:[ABCEFLNPRTVabceflnprtv"''\\]|\d+|[Xx]\h{2}|[Uu](?:\h{4}|\{\h+}))' 338 | name: constant.character.escape.nim 339 | - match: \\ 340 | name: invalid.illegal.lone-escape.nim 341 | - include: $self 342 | - match: '\\(?:[ABCEFLNPRTVabceflnprtv"''\\]|\d+|[Xx]\h{2}|[Uu](?:\h{4}|\{\h+}))' 343 | name: constant.character.escape.nim 344 | - match: \\ 345 | name: invalid.illegal.lone-escape.nim 346 | 347 | generic-param-list: 348 | patterns: 349 | - begin: (?<=[`*\w\x{80}-\x{ff}]) *(\[) 350 | beginCaptures: 351 | '1': {name: punctuation.section.generic.begin.nim} 352 | end: '(])|(?=[^#_`:=,;A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]\s])' 353 | endCaptures: 354 | '1': {name: punctuation.section.generic.end.nim} 355 | name: meta.generic.nim 356 | patterns: 357 | - include: '#generic-param-list-0' 358 | 359 | generic-param-list-0: 360 | patterns: 361 | - match: '[,;]' 362 | name: punctuation.separator.nim 363 | - begin: '(:)|(=)' 364 | beginCaptures: 365 | '1': {name: punctuation.separator.annotation.nim} 366 | '2': {name: keyword.operator.assignment.nim} 367 | end: '([,;])|(?=\])' 368 | endCaptures: 369 | '1': {name: punctuation.separator.nim} 370 | patterns: 371 | - include: '$self' 372 | - include: '#comments' 373 | 374 | pragmas: 375 | patterns: 376 | - begin: \{\.(?!\.}) 377 | beginCaptures: 378 | '0': {name: punctuation.section.annotation.begin.nim} 379 | end: '\.?}' 380 | endCaptures: 381 | '0': {name: punctuation.section.annotation.end.nim} 382 | name: meta.annotation.nim 383 | patterns: 384 | - include: '#calls' 385 | - match: '[A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])*|_|`[^;,\n`]+`' 386 | name: entity.other.attribute-name.pragma.nim 387 | - include: '#square-brackets' 388 | - begin: (?=\S) 389 | end: '(,)|(?=\.?})' 390 | endCaptures: 391 | '1': {name: punctuation.separator.sequence.nim} 392 | patterns: 393 | - begin: ':' 394 | beginCaptures: 395 | '0': {name: punctuation.separator.key-value.nim} 396 | end: (?=,|\.?}) 397 | patterns: 398 | - include: '$self' 399 | 400 | operators: 401 | patterns: 402 | - match: '\b(?:and|not|x?or)\b' 403 | name: keyword.operator.logical.nim 404 | - match: ^of\b 405 | name: keyword.control.conditional.case.nim 406 | - match: '\b(?:of|(?:not)?in|is(?:not)?)\b' 407 | name: keyword.operator.word.nim 408 | - match: \bsh[lr]\b 409 | name: keyword.operator.bitwise.nim 410 | - match: '\b(?:div|mod)\b' 411 | name: keyword.operator.arithmetic.nim 412 | - match: '==|<=?|>=?|!=' 413 | name: keyword.operator.comparison.nim 414 | - match: '(?:[-+*/@$&%|^.:\\∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔][-=+*/<>@$~&%|!?^.:\\∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]*)?=(?![-=+*/<>@$~&%|!?^.:\\∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔])' 415 | name: keyword.operator.assignment.nim 416 | - match: '[-=+*/<>@$~&%|!?^.:\\∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]+' 417 | name: keyword.operator.nim 418 | 419 | literals: 420 | patterns: 421 | - include: '#str_lits' 422 | - include: '#numbers' 423 | - include: '#characters' 424 | - include: '#language-constants' 425 | 426 | str_lits: 427 | patterns: 428 | - include: '#triplestr_lit' 429 | - include: '#rstr_lit' 430 | - include: '#str_lit' 431 | 432 | triplestr_lit: 433 | patterns: 434 | - begin: '([Rr])?(""")' 435 | beginCaptures: 436 | '1': {name: storage.type.nim} 437 | '2': {name: string.quoted.triple.nim punctuation.definition.string.begin.nim} 438 | end: '"""(?!")' 439 | endCaptures: 440 | '0': {name: string.quoted.triple.nim punctuation.definition.string.end.nim} 441 | contentName: string.quoted.triple.nim 442 | 443 | rstr_lit: 444 | patterns: 445 | - begin: '([Rr])(")' 446 | beginCaptures: 447 | '1': {name: storage.type.nim} 448 | '2': {name: string.quoted.double.nim punctuation.definition.string.begin.nim} 449 | end: '("(?!"))|(\n)' 450 | endCaptures: 451 | '1': {name: string.quoted.double.nim punctuation.definition.string.end.nim} 452 | '2': {name: string.quoted.double.nim invalid.illegal.unclosed-string.nim} 453 | contentName: string.quoted.double.nim 454 | patterns: 455 | - match: '""' 456 | name: constant.character.escape.nim 457 | 458 | str_lit: 459 | patterns: 460 | - begin: '"' 461 | beginCaptures: 462 | '0': {name: punctuation.definition.string.begin.nim} 463 | end: '(")|(\n)' 464 | endCaptures: 465 | '1': {name: punctuation.definition.string.end.nim} 466 | '2': {name: invalid.illegal.nim} 467 | name: string.quoted.double.nim 468 | patterns: 469 | - match: '\\(?:[ABCEFLNPRTVabceflnprtv"''\\]|\d+|[Xx]\h{2}|[Uu](?:\h{4}|\{\h+}))' 470 | name: constant.character.escape.nim 471 | - match: \\ 472 | name: invalid.illegal.lone-escape.nim 473 | 474 | numbers: 475 | patterns: 476 | - match: '(?x: 477 | \b(\d(?:_?\d)*) 478 | (?: 479 | (?: 480 | ((\.)\d(?:_?\d)*) 481 | ([Ee][-+]?\d(?:_?\d)*)? 482 | |([Ee][-+]?\d(?:_?\d)*) 483 | ) 484 | (''(?:[A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])*|_)|(?:[Ff](?:32|64)|[Dd]))? 485 | |(''(?:[A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])*|_)|(?:[Ff](?:32|64)|[Dd])) 486 | ) 487 | )' 488 | captures: 489 | '0': {name: meta.number.float.decimal.nim} 490 | '1': {name: constant.numeric.value.nim} 491 | '2': {name: constant.numeric.value.nim} 492 | '3': {name: punctuation.separator.decimal.nim} 493 | '4': {name: constant.numeric.value.exponent.nim} 494 | '5': {name: constant.numeric.value.exponent.nim} 495 | '6': {name: constant.numeric.suffix.nim} 496 | '7': {name: constant.numeric.suffix.nim} 497 | 498 | - match: '(?x: 499 | \b(0[Xx]) 500 | (\h(?:_?\h)*) 501 | (''(?:[A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])*|_)|[Ff](?:32|64)) 502 | )' 503 | captures: 504 | '0': {name: meta.number.float.hexadecimal.nim} 505 | '1': {name: constant.numeric.base.nim} 506 | '2': {name: constant.numeric.value.nim} 507 | '3': {name: constant.numeric.suffix.nim} 508 | 509 | - match: '(?x: 510 | \b(0o) 511 | ([0-7](?:_?[0-7])*) 512 | (''(?:[A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])*|_)|(?:[Ff](?:32|64)|[Dd])) 513 | )' 514 | captures: 515 | '0': {name: meta.number.float.octal.nim} 516 | '1': {name: constant.numeric.base.nim} 517 | '2': {name: constant.numeric.value.nim} 518 | '3': {name: constant.numeric.suffix.nim} 519 | 520 | - match: '(?x: 521 | \b(0[Bb]) 522 | ([01](?:_?[01])*) 523 | (''(?:[A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])*|_)|(?:[Ff](?:32|64)|[Dd])) 524 | )' 525 | captures: 526 | '0': {name: meta.number.float.binary.nim} 527 | '1': {name: constant.numeric.base.nim} 528 | '2': {name: constant.numeric.value.nim} 529 | '3': {name: constant.numeric.suffix.nim} 530 | 531 | 532 | - match: '(?x: 533 | \b(0[Xx]) 534 | (\h(?:_?\h)*) 535 | (''(?:[A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])*|_)|(?:[IUiu](?:8|16|32|64)|[Uu]))? 536 | )' 537 | captures: 538 | '0': {name: meta.number.integer.hexadecimal.nim} 539 | '1': {name: constant.numeric.base.nim} 540 | '2': {name: constant.numeric.value.nim} 541 | '3': {name: constant.numeric.suffix.nim} 542 | 543 | - match: '(?x: 544 | \b(0o) 545 | ([0-7](?:_?[0-7])*) 546 | (''(?:[A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])*|_)|(?:[IUiu](?:8|16|32|64)|[Uu]))? 547 | )' 548 | captures: 549 | '0': {name: meta.number.integer.octal.nim} 550 | '1': {name: constant.numeric.base.nim} 551 | '2': {name: constant.numeric.value.nim} 552 | '3': {name: constant.numeric.suffix.nim} 553 | 554 | - match: '(?x: 555 | \b(0[Bb]) 556 | ([01](?:_?[01])*) 557 | (''(?:[A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])*|_)|(?:[IUiu](?:8|16|32|64)|[Uu]))? 558 | )' 559 | captures: 560 | '0': {name: meta.number.integer.binary.nim} 561 | '1': {name: constant.numeric.base.nim} 562 | '2': {name: constant.numeric.value.nim} 563 | '3': {name: constant.numeric.suffix.nim} 564 | 565 | - match: '(?x: 566 | \b(\d(?:_?\d)*) 567 | (''(?:[A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])*|_)|(?:[IUiu](?:8|16|32|64)|[Uu]))? 568 | )' 569 | captures: 570 | '0': {name: meta.number.integer.decimal.nim} 571 | '1': {name: constant.numeric.value.nim} 572 | '2': {name: constant.numeric.suffix.nim} 573 | 574 | characters: 575 | patterns: 576 | - match: '''(?:[^\\'']|(\\(?:[ABCEFLNRTVabceflnrtv"''\\]|\d+|[Xx]\h{2})))''' 577 | captures: 578 | '0': {name: constant.character.nim} 579 | '1': {name: constant.character.escape.nim} 580 | 581 | - match: '''[^'']+''' 582 | name: invalid.illegal.nim 583 | 584 | language-constants: 585 | patterns: 586 | - match: '\b(?:true|false|nil)\b' 587 | name: constant.language.nim 588 | 589 | keywords: 590 | patterns: 591 | - match: '\b(?:addr|cast)\b' 592 | name: keyword.operator.word.nim 593 | 594 | - begin: \bdiscard +""" 595 | beginCaptures: 596 | '0': {name: punctuation.definition.comment.begin.nim} 597 | end: '"""(?!")' 598 | endCaptures: 599 | '0': {name: punctuation.definition.comment.end.nim} 600 | name: comment.block.nim 601 | 602 | - match: '\b(?:distinct|discard)\b' 603 | name: keyword.other.nim 604 | 605 | - match: '\b(?:asm|end|break|continue|raise|return|yield)\b' 606 | name: keyword.control.flow.nim 607 | 608 | - match: \b(?:concept|enum|interface)\b 609 | name: storage.type.nim 610 | 611 | - match: '\b(object)\b(?: *(of)\b)?' 612 | captures: 613 | '1': {name: storage.type.nim} 614 | '2': {name: keyword.other.nim} 615 | 616 | - match: '\bwhile\b' 617 | name: keyword.control.loop.while.nim 618 | 619 | - match: '\bcase\b' 620 | name: keyword.control.conditional.switch.nim 621 | 622 | - match: '^ *(of)\b' 623 | name: keyword.control.conditional.case.nim 624 | 625 | - match: '\bif\b' 626 | name: keyword.control.conditional.if.nim 627 | 628 | - match: '\bwhen\b' 629 | name: keyword.control.conditional.when.nim 630 | 631 | - match: '\belif\b' 632 | name: keyword.control.conditional.elseif.nim 633 | 634 | - match: '\b(else)\b(?: *(:))?' 635 | captures: 636 | '0': {name: meta.statement.conditional.else.nim} 637 | '1': {name: keyword.control.conditional.else.nim} 638 | '2': {name: punctuation.section.block.conditional.else.nim} 639 | 640 | - match: '\b(try)\b(?: *(:))?' 641 | captures: 642 | '0': {name: meta.statement.exception.try.nim} 643 | '1': {name: keyword.control.exception.try.nim} 644 | '2': {name: punctuation.section.block.exception.nim} 645 | 646 | - match: '\b(finally)\b(?: *(:))?' 647 | captures: 648 | '0': {name: meta.statement.exception.finally.nim} 649 | '1': {name: keyword.control.exception.finally.nim} 650 | '2': {name: punctuation.section.block.exception.finally.nim} 651 | 652 | - match: '\b(defer)\b(?: *(:))?' 653 | captures: 654 | '1': {name: keyword.control.flow.defer.nim} 655 | '2': {name: punctuation.section.block.begin.nim} 656 | 657 | - match: '\b(block)\b(?:(?: *(?:[A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])*|_|`[^;,\n`]+`))? *(:))?' 658 | captures: 659 | '1': {name: keyword.declaration.block.nim} 660 | '2': {name: punctuation.section.block.begin.nim} 661 | 662 | - match: '\b(?:as|(?:ex|im)port|include|bind|mixin|from|except)\b' 663 | name: keyword.control.nim 664 | 665 | - match: '\b(?:const|let|var|using)\b' 666 | name: storage.modifier.nim 667 | 668 | do-stmts: 669 | patterns: 670 | - begin: \bdo\b 671 | beginCaptures: 672 | '0': {name: storage.type.function.nim} 673 | end: '(->)|(?=[^\-\( ])' 674 | endCaptures: 675 | '1': {name: punctuation.separator.annotation.return.nim} 676 | patterns: 677 | - include: '#param-list' 678 | 679 | calls: 680 | patterns: 681 | - begin: '(?x: 682 | (?= 683 | (?: 684 | (?!(?:out|ptr|ref|tuple)\b) 685 | [A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])*|_|`[^;,\n`]+` 686 | ) 687 | (?:\[.*])? 688 | (?: 689 | \( 690 | |" 691 | |[ ]+ 692 | (?: 693 | [_\d"''`\[\(] 694 | |(?!\.|(?:\*?[ ]*)[:=]|=[^=])[-=+*/<>@$~&%|!?^.:\\∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]+[^\-=+*/<>@$~&%|!?^.:\\∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔\s] 695 | |(?!(as|asm|and|bind|break|concept|const|continue|converter 696 | |defer|discard|distinct|div|elif|else|end|except|export|finally|from|import 697 | |include|interface|is(?:not)?|let|macro|method|mixin|mod|(?:not)?in|of 698 | |raise|sh[lr]|template|using|while|yield|x?or)\b)[A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]] 699 | |\{(?!\.) 700 | ) 701 | ) 702 | ) 703 | )' 704 | end: '(?=[^\[\(`\w\x{80}-\x{ff}])|(?<=["\)])' 705 | patterns: 706 | - begin: '(?=[`_A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])' 707 | end: '(?=[^`_A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])' 708 | name: entity.name.function.nim 709 | patterns: 710 | - include: '#builtins' 711 | - match: '[A-Z][\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]]+\b' 712 | name: support.type.nim 713 | - match: '[A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])*|_|`[^;,\n`]+`' 714 | 715 | - begin: '\[:?' 716 | beginCaptures: 717 | '0': {name: punctuation.section.generic.begin.nim} 718 | end: ']' 719 | endCaptures: 720 | '0': {name: punctuation.section.generic.end.nim} 721 | name: meta.function-call.nim meta.generic.nim 722 | patterns: 723 | - include: $self 724 | - begin: '\(' 725 | beginCaptures: 726 | '0': {name: punctuation.section.arguments.begin.nim} 727 | end: (\)) 728 | endCaptures: 729 | '1': {name: punctuation.section.arguments.end.nim} 730 | name: meta.function-call.arguments.nim 731 | patterns: 732 | - include: $self 733 | - include: '#triplestr_lit' 734 | - begin: '"' 735 | beginCaptures: 736 | '0': {name: punctuation.definition.string.begin.nim} 737 | end: '("(?!"))|(\n)' 738 | endCaptures: 739 | '1': {name: punctuation.definition.string.end.nim} 740 | '2': {name: invalid.illegal.unclosed-string.nim} 741 | name: string.quoted.double.nim 742 | patterns: 743 | - match: '""' 744 | name: constant.character.escape.nim 745 | 746 | types: 747 | patterns: 748 | - begin: '(?=(?:[A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z])*)\[)(?x:(out|ptr|ref|array 749 | |cstring[Aa]rray|iterable|lent|open[Aa]rray|owned|ptr|range|ref|se[qt] 750 | |sink|static|type(?:[Dd]esc)?|varargs)|([A-Z][\dA-Za-z]+))(\[)' 751 | beginCaptures: 752 | '1': {name: storage.type.primitive.nim} 753 | '2': {name: support.type.nim} 754 | '3': {name: meta.generic.nim punctuation.section.generic.begin.nim} 755 | end: ']' 756 | endCaptures: 757 | '0': {name: meta.generic.nim punctuation.section.generic.nim} 758 | contentName: meta.generic.nim 759 | patterns: 760 | - include: $self 761 | 762 | - match: \b(?:out|tuple|ref|ptr)\b 763 | name: storage.type.primitive.nim 764 | 765 | builtins: 766 | patterns: 767 | - match: \bresult\b 768 | name: variable.language.nim 769 | 770 | - match: '\b(?x:any|array|auto|bool|byte 771 | |c(?:double|float|u?(?:long(?:long)?|char|int|short)|longdouble|schar 772 | |size(?:_t)?|string(?:[Aa]rray)?) 773 | |char|float(?:32|64)?|iterable|lent|open[Aa]rray|owned|pointer|ptr|range|ref|se[qt] 774 | |sink|static|string|typed?|type[Dd]esc|u?int(?:8|16|32|64)?|untyped|varargs|void)\b' 775 | name: storage.type.primitive.nim 776 | 777 | - match: '\b(?x:appType|Compile(?:Date|Time)|cpuEndian 778 | |host(?:CPU|OS) 779 | |isMainModule|NaN|(?:Neg)?Inf|Nim(?:Major|Minor|Patch|Version)|nimvm|off|on 780 | |Quit(?:Failure|Success))\b' 781 | name: support.constant.builtin.nim 782 | 783 | generic-symbols: 784 | patterns: 785 | - match: '[A-Z](_?[A-Z\d\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])+\b' 786 | name: support.constant.nim 787 | - match: '[A-Z][\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]]+\b' 788 | name: support.type.nim 789 | - match: '[A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])*|_|`[^;,\n`]+`' 790 | -------------------------------------------------------------------------------- /Syntaxes/Nim.sublime-syntax: -------------------------------------------------------------------------------- 1 | %YAML 1.2 2 | --- 3 | name: Nim 4 | file_extensions: [nim, nims, nimble] 5 | scope: source.nim 6 | version: 2 7 | variables: 8 | letter_bare: 'A-Za-z\x80-\x{10FFFF}&&[^{{UNICODE_OPR}}]' 9 | letter: '[{{letter_bare}}]' 10 | ident: '{{letter}}(?:_?[\d{{letter_bare}}])*|_' 11 | symbol: '{{ident}}|`[^;,\n`]+`' 12 | symbol_lookahead: '(?={{letter}}|\(|`|_\b)' 13 | pragma_start: '\{\.(?!\.})' 14 | string_escape_chars: '\\(?:[ABCEFLNPRTVabceflnprtv"''\\]|\d+|[Xx]\h{2}|[Uu](?:\h{4}|\{\h+}))' 15 | UNICODE_OPR: '∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔' 16 | OPR: '-=\+\*/<>@\$~&%\|!\?\^\.:\\{{UNICODE_OPR}}' 17 | format_spec: '=?(?: *:[^}]*)?' 18 | disallowed_keyws: '(?x:as|asm|and|bind|break|concept|const|continue|converter 19 | |defer|discard|distinct|div|elif|else|end|except|export|finally|from|import 20 | |include|interface|is(?:not)?|let|macro|method|mixin|mod|(?:not)?in|of 21 | |raise|sh[lr]|template|using|while|yield|x?or)' 22 | keyws: '(?x:{{disallowed_keyws}}|addr|block|case|cast|do|enum|for|func|if|iterator 23 | |object|out|proc|ptr|ref|return|static|try|tuple|type|var|when)\b' 24 | generic_builtin_types: '(?x:out|ptr|ref|array|cstring[Aa]rray|iterable|lent 25 | |open[Aa]rray|owned|range|se[qt]|sink|static|type(?:desc)?|varargs)' 26 | builtin_types: '(?x:any|array|auto|bool|byte 27 | |c(?:double|float|u?(?:long(?:long)?|char|int|short)|longdouble|schar 28 | |size(?:_t)?|string(?:[Aa]rray)?) 29 | |char|float(?:32|64)?|iterable|lent|open[Aa]rray|owned|pointer|ptr|range|ref|se[qt] 30 | |sink|static|string|typed?|typedesc|u?int(?:8|16|32|64)?|untyped|varargs|void)' 31 | builtin_constants: '(?x:appType|Compile(?:Date|Time)|cpuEndian 32 | |host(?:CPU|OS) 33 | |isMainModule|NaN|(?:Neg)?Inf|Nim(?:Major|Minor|Patch|Version)|nimvm|off|on 34 | |Quit(?:Failure|Success))' 35 | float_suffix: '''(?:{{ident}})|(?:[Ff](?:32|64)|[Dd])' 36 | int_suffix: '''(?:{{ident}})|(?:[IUiu](?:8|16|32|64)|[Uu])' 37 | 38 | 39 | contexts: 40 | 41 | main: 42 | - include: type-defs 43 | - include: const-defs 44 | - include: var-let-using-defs 45 | - include: pragmas 46 | - include: brackets 47 | - include: punctuations 48 | - include: doc-comments 49 | - include: comments 50 | - include: for-stmts 51 | - include: asm-stmts 52 | - include: routines 53 | - include: fmt-strs 54 | - include: operators 55 | - include: literals 56 | - include: do-stmts 57 | - include: keywords 58 | - include: calls 59 | - include: types 60 | - include: builtins 61 | - include: generic-symbols 62 | 63 | else-pop: 64 | - match: (?=\S) 65 | pop: true 66 | 67 | generic-symbols: 68 | - match: '[A-Z](_?[\d{{letter_bare}}&&[^a-z]])+\b' 69 | scope: support.constant.nim 70 | - match: '[A-Z](_?[\d{{letter_bare}}])+\b' 71 | scope: support.type.nim 72 | - match: '{{symbol}}' 73 | 74 | types: 75 | - match: \btuple(?=\[) 76 | scope: storage.type.primitive.nim 77 | push: generic-param-list 78 | - match: '\b(?=(?:{{ident}})\[)(?:({{generic_builtin_types}})|([A-Z][\d{{letter_bare}}]+))(\[)' 79 | captures: 80 | 1: storage.type.primitive.nim 81 | 2: support.type.nim 82 | 3: meta.generic.nim punctuation.section.generic.begin.nim 83 | push: 84 | - meta_content_scope: meta.generic.nim 85 | - match: ']' 86 | scope: meta.generic.nim punctuation.section.generic.end.nim 87 | pop: true 88 | - include: main 89 | - match: \b(?:out|tuple|ref|ptr)\b 90 | scope: storage.type.primitive.nim 91 | 92 | brackets: 93 | - include: square-brackets 94 | - match: '\{' 95 | scope: punctuation.section.braces.begin.nim 96 | push: 97 | - meta_scope: meta.braces.nim 98 | - match: '}' 99 | scope: punctuation.section.braces.end.nim 100 | pop: true 101 | - include: main 102 | 103 | - match: '\(' 104 | scope: punctuation.section.parens.begin.nim 105 | push: 106 | - meta_scope: meta.parens.nim 107 | - match: '\)' 108 | scope: punctuation.section.parens.end.nim 109 | pop: true 110 | - include: main 111 | 112 | square-brackets: 113 | - match: '\[' 114 | scope: punctuation.section.brackets.begin.nim 115 | push: 116 | - meta_scope: meta.brackets.nim 117 | - match: ']' 118 | scope: punctuation.section.brackets.end.nim 119 | pop: true 120 | - include: main 121 | 122 | builtins: 123 | - match: \bresult\b 124 | scope: variable.language.nim 125 | 126 | - match: \b(?:{{builtin_types}})\b 127 | scope: storage.type.primitive.nim 128 | 129 | - match: \b(?:{{builtin_constants}})\b 130 | scope: support.constant.builtin.nim 131 | 132 | type-defs: 133 | - match: '^ *(type) +(?:(?:{{symbol}}) *(\.))?({{symbol}})(?: *(\*))?' 134 | captures: 135 | 1: keyword.declaration.type.nim 136 | 2: punctuation.accessor.dot.nim 137 | 3: entity.name.type.nim 138 | 4: storage.modifier.nim 139 | push: generic-param-list 140 | 141 | - match: ^type\b 142 | scope: keyword.declaration.type.nim 143 | push: 144 | - match: ^(?! |$) 145 | pop: true 146 | - match: '^ (?:(?:{{symbol}}) *(\.))?({{symbol}})(?: *(\*))?' 147 | captures: 148 | 1: punctuation.accessor.dot.nim 149 | 2: entity.name.type.nim 150 | 3: storage.modifier.nim 151 | push: generic-param-list 152 | - include: main 153 | 154 | const-defs: 155 | - match: \b(const) +{{symbol_lookahead}} 156 | captures: 157 | 1: storage.modifier.nim keyword.declaration.constant.nim 158 | push: const-name 159 | - match: ^const\b 160 | scope: storage.modifier.nim keyword.declaration.constant.nim 161 | push: 162 | - match: ^(?! |$) 163 | pop: true 164 | - match: '^ {{symbol_lookahead}}' 165 | push: const-name 166 | - include: main 167 | 168 | const-name: 169 | - match: '({{keyws}})(?: *(\*))?' 170 | captures: 171 | 1: invalid.illegal.nim 172 | 2: storage.modifier.nim 173 | pop: true 174 | - match: '({{symbol}})(?: *(\*))?' 175 | captures: 176 | 1: entity.name.constant.nim 177 | 2: storage.modifier.nim 178 | set: 179 | - include: comments 180 | - include: pragmas 181 | - match: (:)|(=) 182 | captures: 183 | 1: punctuation.separator.annotation.nim 184 | 2: keyword.operator.assignment.nim 185 | pop: true 186 | - match: ',' 187 | scope: invalid.illegal.nim 188 | pop: true 189 | - include: else-pop 190 | - match: '\(' 191 | scope: punctuation.section.parens.begin.nim 192 | set: 193 | - match: '\)' 194 | scope: punctuation.section.parens.end.nim 195 | set: 196 | - include: comments 197 | - match: ':' 198 | scope: invalid.illegal.nim 199 | pop: true 200 | - include: else-pop 201 | - match: '({{keyws}})(?: *(\*))?' 202 | captures: 203 | 1: invalid.illegal.nim 204 | 2: storage.modifier.nim 205 | - match: '({{symbol}})(?: *(\*))?' 206 | captures: 207 | 1: entity.name.constant.nim 208 | 2: storage.modifier.nim 209 | - match: ',' 210 | scope: punctuation.separator.nim 211 | - include: pragmas 212 | - include: doc-comments 213 | - include: comments 214 | - include: else-pop 215 | 216 | var-let-using-defs: 217 | - match: (?:^|(;)) *(var|let|using) +{{symbol_lookahead}} 218 | captures: 219 | 1: punctuation.terminator.nim 220 | 2: storage.modifier.nim keyword.declaration.variable.nim 221 | push: var-name 222 | - match: ^(?:var|let|using)\b 223 | scope: storage.modifier.nim keyword.declaration.variable.nim 224 | push: 225 | - match: ^(?! |$) 226 | pop: true 227 | - match: '^ {{symbol_lookahead}}' 228 | push: var-name 229 | - include: main 230 | 231 | var-name: 232 | - match: '\(' 233 | scope: punctuation.section.parens.begin.nim 234 | set: 235 | - match: '\)' 236 | scope: punctuation.section.parens.end.nim 237 | set: 238 | - include: comments 239 | - match: ':' 240 | scope: invalid.illegal.nim 241 | pop: true 242 | - include: else-pop 243 | - include: var-name-0 244 | - match: '(?!{{keyws}})({{symbol}})(?: *(\*))?' 245 | captures: 246 | 1: entity.name.variable.nim 247 | 2: storage.modifier.nim 248 | push: 249 | - match: ',' 250 | scope: punctuation.separator.nim 251 | set: 252 | - include: doc-comments 253 | - include: comments 254 | - match: (?=[^ ]) 255 | pop: true 256 | - include: pragmas 257 | - include: comments 258 | - match: '{{symbol}}' 259 | scope: invalid.illegal.nim 260 | pop: true 261 | - match: (?=[^ ]) 262 | pop: true 263 | - match: ':' 264 | scope: punctuation.separator.annotation.nim 265 | pop: true 266 | - match: (?=[^ ]) 267 | pop: true 268 | 269 | var-name-0: 270 | - match: '(?!{{keyws}})({{symbol}})(?: *(\*))?' 271 | captures: 272 | 1: entity.name.variable.nim 273 | 2: storage.modifier.nim 274 | push: 275 | - match: ',' 276 | scope: punctuation.separator.nim 277 | set: 278 | - include: doc-comments 279 | - include: comments 280 | - include: else-pop 281 | - include: pragmas 282 | - include: comments 283 | - match: '{{symbol}}' 284 | scope: invalid.illegal.nim 285 | pop: true 286 | - include: else-pop 287 | - match: ':' 288 | scope: punctuation.separator.annotation.nim 289 | pop: true 290 | - include: else-pop 291 | 292 | do-stmts: 293 | - match: \bdo\b 294 | scope: storage.type.function.nim keyword.declaration.function.nim 295 | push: [do-stmts-1, do-stmts-0] 296 | 297 | do-stmts-0: 298 | - match: '\(' 299 | scope: meta.function.parameters.nim punctuation.section.parameters.begin.nim 300 | set: 301 | - meta_content_scope: meta.function.parameters.nim 302 | - match: '{{symbol}}' 303 | scope: meta.function.parameters.nim variable.parameter.nim 304 | set: [param-list, decl-col-eq-1] 305 | - match: '\)' 306 | scope: meta.function.parameters.nim punctuation.section.parameters.end.nim 307 | pop: true 308 | - include: else-pop 309 | - include: else-pop 310 | 311 | do-stmts-1: 312 | - match: '->' 313 | scope: punctuation.separator.annotation.return.nim 314 | - include: else-pop 315 | 316 | calls: 317 | - match: '(?x: 318 | (?=(?:(?!(?:out|ptr|ref|tuple)\b){{symbol}}) 319 | (?:\[.*])? 320 | (?: 321 | \( 322 | |" 323 | |[ ]+ 324 | (?: 325 | [_\d"''`\[\(] 326 | |(?!\.|(?:\* *)?[:=]|=[^=])[{{OPR}}]+[^{{OPR}}\s] 327 | |(?!{{disallowed_keyws}}\b){{letter}} 328 | |\{(?!\.) 329 | ) 330 | ) 331 | ) 332 | )' 333 | push: [args-list, routine-name] 334 | 335 | routine-name: 336 | - meta_content_scope: meta.function-call.nim variable.function.nim 337 | - include: builtins 338 | - include: generic-symbols 339 | - match: '' 340 | set: generic 341 | 342 | generic: 343 | - match: '\[:?' 344 | scope: punctuation.section.generic.begin.nim 345 | set: 346 | - meta_scope: meta.function-call.nim meta.generic.nim 347 | - match: ']' 348 | scope: punctuation.section.generic.end.nim 349 | pop: true 350 | - include: main 351 | - match: '' 352 | pop: true 353 | 354 | args-list: 355 | - match: '\(' 356 | scope: punctuation.section.arguments.begin.nim 357 | set: 358 | - meta_scope: meta.function-call.arguments.nim 359 | - match: '\)' 360 | scope: punctuation.section.arguments.end.nim 361 | pop: true 362 | - match: '(?x: 363 | (?= 364 | (?:{{symbol}}) 365 | [ ]* 366 | [:=](?![{{OPR}}]) 367 | ) 368 | (?!{{keyws}})({{symbol}}) 369 | (?:[ ]*(:))? 370 | | 371 | (?=\S) 372 | )' 373 | captures: 374 | 1: variable.parameter.nim 375 | 2: punctuation.separator.key-value.nim 376 | push: 377 | - match: (?=\)) 378 | pop: true 379 | - match: ',' 380 | scope: punctuation.separator.nim 381 | set: 382 | - include: comments 383 | - include: else-pop 384 | - include: main 385 | - match: '"""' 386 | scope: meta.string.nim string.quoted.double.block.nim punctuation.definition.string.begin.nim 387 | set: triplestr_lit_inner 388 | - match: '"' 389 | scope: meta.string.nim string.quoted.double.nim punctuation.definition.string.begin.nim 390 | set: rstr_lit_inner 391 | - match: '' 392 | pop: true 393 | 394 | punctuations: 395 | - match: ';' 396 | scope: punctuation.terminator.statement.nim 397 | - match: ',' 398 | scope: punctuation.separator.nim 399 | - match: ':' 400 | scope: punctuation.section.block.begin.nim 401 | - match: \.(?![{{OPR}}]) 402 | scope: punctuation.accessor.dot.nim 403 | - match: '(\*) *(:|(?=,|#|\{\.))' 404 | captures: 405 | 1: storage.modifier.nim 406 | 2: punctuation.separator.annotation.nim 407 | - match: '\)|]|}' 408 | scope: invalid.illegal.nim 409 | 410 | doc-comments: 411 | - include: block-doc-comment 412 | - include: line-doc-comment 413 | 414 | comments: 415 | - include: block-comment 416 | - include: line-comment 417 | 418 | comment: 419 | - include: comments 420 | - include: else-pop 421 | 422 | no-doc-comment: 423 | - match: '(?=##)' 424 | pop: true 425 | - include: comment 426 | 427 | line-comment: 428 | - match: '(#)(?: *(TODO|todo))?' 429 | captures: 430 | 1: punctuation.definition.comment.nim 431 | 2: invalid.deprecated.nim 432 | push: 433 | - meta_scope: comment.line.number-sign.nim 434 | - match: '$\n?' 435 | pop: true 436 | 437 | block-comment: 438 | - match: '#\[' 439 | scope: comment.block.nim punctuation.definition.comment.begin.nim 440 | push: 441 | - meta_content_scope: comment.block.nim 442 | - match: '\]#' 443 | scope: comment.block.nim punctuation.definition.comment.end.nim 444 | pop: true 445 | - include: block-comment 446 | 447 | line-doc-comment: 448 | - match: '##' 449 | scope: punctuation.definition.comment.nim 450 | push: 451 | - meta_scope: comment.line.documentation.nim 452 | - match: '$\n?' 453 | pop: true 454 | 455 | block-doc-comment: 456 | - match: '##\[' 457 | scope: punctuation.definition.comment.begin.nim 458 | push: 459 | - meta_scope: comment.block.documentation.nim 460 | - match: ']##' 461 | scope: punctuation.definition.comment.end.nim 462 | pop: true 463 | - include: block-doc-comment 464 | 465 | str_lits: 466 | - include: triplestr_lit 467 | - include: rstr_lit 468 | - include: str_lit 469 | 470 | str_lit: 471 | - match: '"' 472 | scope: punctuation.definition.string.begin.nim 473 | push: str_lit_inner 474 | 475 | str_lit_inner: 476 | - meta_scope: meta.string.nim string.quoted.double.nim 477 | - match: '{{string_escape_chars}}' 478 | scope: constant.character.escape.nim 479 | - match: \\ 480 | scope: invalid.illegal.lone-escape.nim 481 | - match: '"' 482 | scope: punctuation.definition.string.end.nim 483 | pop: true 484 | - match: \n 485 | scope: invalid.illegal.nim 486 | pop: true 487 | 488 | rstr_lit: 489 | - match: '([Rr])(")' 490 | captures: 491 | 0: meta.string.nim 492 | 1: storage.type.string.nim 493 | 2: string.quoted.double.nim punctuation.definition.string.begin.nim 494 | push: rstr_lit_inner 495 | 496 | rstr_lit_inner: 497 | - meta_content_scope: meta.string.nim string.quoted.double.nim 498 | - match: '""' 499 | scope: constant.character.escape.double-quote.nim 500 | - match: '"' 501 | scope: meta.string.nim string.quoted.double.nim punctuation.definition.string.end.nim 502 | pop: true 503 | - match: '\n' 504 | scope: meta.string.nim string.quoted.double.nim invalid.illegal.unclosed-string.nim 505 | pop: true 506 | 507 | triplestr_lit: 508 | - match: '([Rr])?(""")' 509 | captures: 510 | 0: meta.string.nim 511 | 1: storage.type.string.nim 512 | 2: string.quoted.double.block.nim punctuation.definition.string.begin.nim 513 | push: triplestr_lit_inner 514 | 515 | triplestr_lit_inner: 516 | - meta_content_scope: meta.string.nim string.quoted.double.block.nim 517 | - match: '"""(?!")' 518 | scope: meta.string.nim string.quoted.double.block.nim punctuation.definition.string.end.nim 519 | pop: true 520 | 521 | fmt-strs: 522 | - match: '(?:(fmt)|(&))(""")' 523 | captures: 524 | 1: meta.function-call.nim variable.function.nim 525 | 2: keyword.operator.nim 526 | 3: meta.string.interpolated.nim string.quoted.double.block.nim punctuation.definition.string.begin.nim 527 | push: 528 | - meta_content_scope: meta.string.interpolated.nim string.quoted.double.block.nim 529 | - match: '{{|}}' 530 | scope: constant.character.escape.nim 531 | - match: '}' 532 | scope: invalid.illegal.nim 533 | - match: '{' 534 | scope: punctuation.section.interpolation.begin.nim 535 | push: 536 | - clear_scopes: 1 537 | - meta_scope: meta.interpolation.nim 538 | - match: '(?="""[^"])' 539 | pop: true 540 | - match: '({{format_spec}}) *(})' 541 | captures: 542 | 1: constant.other.format-spec.nim 543 | 2: punctuation.section.interpolation.end.nim 544 | pop: true 545 | - include: main 546 | with_prototype: 547 | - match: '\\{|\\}' 548 | scope: constant.character.escape.nim 549 | - match: '{' 550 | scope: invalid.illegal.nim 551 | - match: '"""(?!")' 552 | scope: meta.string.interpolated.nim string.quoted.double.block.nim punctuation.definition.string.end.nim 553 | pop: true 554 | - match: (fmt)(") 555 | captures: 556 | 1: meta.function-call.nim variable.function.nim 557 | 2: meta.string.interpolated.nim string.quoted.double.nim punctuation.definition.string.begin.nim 558 | push: 559 | - meta_content_scope: meta.string.interpolated.nim string.quoted.double.nim 560 | - match: '{{|}}' 561 | scope: constant.character.escape.nim 562 | - match: '}' 563 | scope: invalid.illegal.nim 564 | - match: '{' 565 | scope: punctuation.section.interpolation.begin.nim 566 | push: 567 | - clear_scopes: 1 568 | - meta_scope: meta.interpolation.nim 569 | - match: \n 570 | scope: invalid.illegal.nim 571 | pop: true 572 | - match: '(?=")' 573 | pop: true 574 | - match: '({{format_spec}}) *(})' 575 | captures: 576 | 1: constant.other.format-spec.nim 577 | 2: punctuation.section.interpolation.end.nim 578 | pop: true 579 | - include: main 580 | with_prototype: 581 | - match: '\\{|\\}' 582 | scope: constant.character.escape.nim 583 | - match: '{' 584 | scope: invalid.illegal.nim 585 | - match: '""' 586 | scope: meta.string.interpolated.nim string.quoted.double.nim constant.character.escape.double-quotes.nim 587 | - match: \n 588 | scope: invalid.illegal.nim 589 | pop: true 590 | - match: '"' 591 | scope: meta.string.interpolated.nim string.quoted.double.nim punctuation.definition.string.end.nim 592 | pop: true 593 | - match: (&)(") 594 | captures: 595 | 1: meta.string.interpolated.nim keyword.operator.nim 596 | 2: meta.string.interpolated.nim string.quoted.double.nim punctuation.definition.string.begin.nim 597 | push: 598 | - meta_content_scope: meta.string.interpolated.nim string.quoted.double.nim 599 | - match: '{{|}}' 600 | scope: constant.character.escape.nim 601 | - match: '}' 602 | scope: invalid.illegal.nim 603 | - match: '{' 604 | scope: punctuation.section.interpolation.begin.nim 605 | push: 606 | - clear_scopes: 1 607 | - meta_scope: meta.interpolation.nim 608 | - match: '{{string_escape_chars}}' 609 | scope: constant.character.escape.nim 610 | - match: \\ 611 | scope: invalid.illegal.lone-escape.nim 612 | - match: \n 613 | scope: invalid.illegal.nim 614 | pop: true 615 | - match: '(?=")' 616 | pop: true 617 | - match: '({{format_spec}}) *(})' 618 | captures: 619 | 1: constant.other.format-spec.nim 620 | 2: punctuation.section.interpolation.end.nim 621 | pop: true 622 | - include: main 623 | with_prototype: 624 | - match: '\\{|\\}' 625 | scope: constant.character.escape.nim 626 | - match: '{' 627 | scope: invalid.illegal.nim 628 | - match: '{{string_escape_chars}}' 629 | scope: constant.character.escape.nim 630 | - match: \\ 631 | scope: invalid.illegal.lone-escape.nim 632 | - match: \n 633 | scope: invalid.illegal.nim 634 | pop: true 635 | - match: '"' 636 | scope: meta.string.interpolated.nim string.quoted.double.nim punctuation.definition.string.end.nim 637 | pop: true 638 | 639 | interpolation: 640 | - match: (?=`) 641 | push: 642 | - clear_scopes: 1 643 | - match: '(`)(?:{{ident}})?(`)' 644 | captures: 645 | 0: meta.interpolation.nim 646 | 1: punctuation.section.interpolation.begin.nim 647 | 2: punctuation.section.interpolation.end.nim 648 | pop: true 649 | - match: '' 650 | pop: true 651 | 652 | numbers: 653 | - match: '(?x: 654 | \b(\d(?:_?\d)*) 655 | (?: 656 | (?: 657 | ((\.)\d(?:_?\d)*) 658 | ([Ee][-+]?\d(?:_?\d)*)? 659 | |([Ee][-+]?\d(?:_?\d)*) 660 | ) 661 | ({{float_suffix}})? 662 | |({{float_suffix}}) 663 | ) 664 | )' 665 | captures: 666 | 0: meta.number.float.decimal.nim 667 | 1: constant.numeric.value.nim 668 | 2: constant.numeric.value.nim 669 | 3: punctuation.separator.decimal.nim 670 | 4: constant.numeric.value.exponent.nim 671 | 5: constant.numeric.value.exponent.nim 672 | 6: constant.numeric.suffix.nim 673 | 7: constant.numeric.suffix.nim 674 | 675 | - match: '(?x: 676 | \b(0[Xx]) 677 | (\h(?:_?\h)*) 678 | (''(?:{{ident}})|[Ff](?:32|64)) 679 | )' 680 | captures: 681 | 0: meta.number.float.hexadecimal.nim 682 | 1: constant.numeric.base.nim 683 | 2: constant.numeric.value.nim 684 | 3: constant.numeric.suffix.nim 685 | 686 | - match: '(?x: 687 | \b(0o) 688 | ([0-7](?:_?[0-7])*) 689 | ({{float_suffix}}) 690 | )' 691 | captures: 692 | 0: meta.number.float.octal.nim 693 | 1: constant.numeric.base.nim 694 | 2: constant.numeric.value.nim 695 | 3: constant.numeric.suffix.nim 696 | 697 | - match: '(?x: 698 | \b(0[Bb]) 699 | ([01](?:_?[01])*) 700 | ({{float_suffix}}) 701 | )' 702 | captures: 703 | 0: meta.number.float.binary.nim 704 | 1: constant.numeric.base.nim 705 | 2: constant.numeric.value.nim 706 | 3: constant.numeric.suffix.nim 707 | 708 | 709 | - match: '(?x: 710 | \b(0[Xx]) 711 | (\h(?:_?\h)*) 712 | ({{int_suffix}})? 713 | )' 714 | captures: 715 | 0: meta.number.integer.hexadecimal.nim 716 | 1: constant.numeric.base.nim 717 | 2: constant.numeric.value.nim 718 | 3: constant.numeric.suffix.nim 719 | 720 | - match: '(?x: 721 | \b(0o) 722 | ([0-7](?:_?[0-7])*) 723 | ({{int_suffix}})? 724 | )' 725 | captures: 726 | 0: meta.number.integer.octal.nim 727 | 1: constant.numeric.base.nim 728 | 2: constant.numeric.value.nim 729 | 3: constant.numeric.suffix.nim 730 | 731 | - match: '(?x: 732 | \b(0[Bb]) 733 | ([01](?:_?[01])*) 734 | ({{int_suffix}})? 735 | )' 736 | captures: 737 | 0: meta.number.integer.binary.nim 738 | 1: constant.numeric.base.nim 739 | 2: constant.numeric.value.nim 740 | 3: constant.numeric.suffix.nim 741 | 742 | - match: '(?x: 743 | \b(\d(?:_?\d)*) 744 | ({{int_suffix}})? 745 | )' 746 | captures: 747 | 0: meta.number.integer.decimal.nim 748 | 1: constant.numeric.value.nim 749 | 2: constant.numeric.suffix.nim 750 | 751 | characters: 752 | - match: '''(?:[^\\'']|(\\(?:[ABCEFLNRTVabceflnrtv"''\\]|\d+|[Xx]\h{2})))''' 753 | captures: 754 | 0: constant.character.nim 755 | 1: constant.character.escape.nim 756 | 757 | - match: '''[^'']+''' 758 | scope: invalid.illegal.nim 759 | 760 | language-constants: 761 | - match: '\b(?:true|false|nil)\b' 762 | scope: constant.language.nim 763 | 764 | literals: 765 | - include: str_lits 766 | - include: numbers 767 | - include: characters 768 | - include: language-constants 769 | 770 | keywords: 771 | - match: '\b(?:addr|cast)\b' 772 | scope: keyword.operator.word.nim 773 | 774 | - match: \bdiscard +""" 775 | scope: punctuation.definition.comment.begin.nim 776 | push: 777 | - meta_scope: comment.block.nim 778 | - match: '"""(?!")' 779 | scope: punctuation.definition.comment.end.nim 780 | pop: true 781 | 782 | - match: '\b(?:distinct|discard)\b' 783 | scope: keyword.other.nim 784 | 785 | - match: '\b(?:asm|end|break|continue|raise|return|yield)\b' 786 | scope: keyword.control.flow.nim 787 | 788 | - match: \b(?:concept|enum|interface)\b 789 | scope: storage.type.nim 790 | 791 | - match: '\b(object)\b(?: *(of)\b)?' 792 | captures: 793 | 1: storage.type.nim 794 | 2: keyword.other.nim 795 | 796 | - match: '\bwhile\b' 797 | scope: keyword.control.loop.while.nim 798 | 799 | - match: '\bcase\b' 800 | scope: keyword.control.conditional.switch.nim 801 | 802 | - match: '^ *(of)\b' 803 | scope: keyword.control.conditional.case.nim 804 | 805 | - match: '\bif\b' 806 | scope: keyword.control.conditional.if.nim 807 | 808 | - match: '\bwhen\b' 809 | scope: keyword.control.conditional.when.nim 810 | 811 | - match: '\belif\b' 812 | scope: keyword.control.conditional.elseif.nim 813 | 814 | - match: '\b(else)\b(?: *(:))?' 815 | captures: 816 | 1: keyword.control.conditional.else.nim 817 | 2: punctuation.section.block.conditional.else.nim 818 | 819 | - match: '\b(try)\b(?: *(:))?' 820 | captures: 821 | 1: keyword.control.exception.try.nim 822 | 2: punctuation.section.block.exception.nim 823 | 824 | - match: '\b(finally)\b(?: *(:))?' 825 | captures: 826 | 1: keyword.control.exception.finally.nim 827 | 2: punctuation.section.block.exception.finally.nim 828 | 829 | - match: '\b(defer)\b(?: *(:))?' 830 | captures: 831 | 1: keyword.control.flow.defer.nim 832 | 2: punctuation.section.block.begin.nim 833 | 834 | - match: '\b(block)\b(?:(?: *(?:{{symbol}}))? *(:))?' 835 | captures: 836 | 1: keyword.declaration.block.nim 837 | 2: punctuation.section.block.begin.nim 838 | 839 | - match: '\b(?:as|(?:ex|im)port|include|bind|mixin|from|except)\b' 840 | scope: keyword.control.nim 841 | 842 | - match: '\b(?:const|let|using)\b' 843 | scope: storage.modifier.nim keyword.declaration.nim 844 | 845 | - match: \bvar\b 846 | scope: storage.modifier.nim 847 | 848 | asm-stmts: 849 | - match: \basm\b 850 | scope: keyword.control.flow.nim 851 | push: [asm-stmt-1, pragma-0] 852 | 853 | asm-stmt-1: 854 | - match: '([Rr])?(""")' 855 | captures: 856 | 0: meta.string.nim 857 | 1: storage.type.string.nim 858 | 2: string.quoted.double.block.nim punctuation.definition.string.begin.nim 859 | set: 860 | - meta_content_scope: meta.string.nim string.quoted.double.block.nim 861 | - include: triplestr_lit_inner 862 | - include: interpolation 863 | - match: '([Rr])(")' 864 | captures: 865 | 0: meta.string.nim 866 | 1: storage.type.string.nim 867 | 2: string.quoted.double.nim punctuation.definition.string.begin.nim 868 | set: 869 | - meta_content_scope: meta.string.nim string.quoted.double.nim 870 | - include: rstr_lit_inner 871 | - include: interpolation 872 | - match: '"' 873 | scope: punctuation.definition.string.begin.nim 874 | set: 875 | - meta_scope: meta.string.nim string.quoted.double.nim 876 | - include: str_lit_inner 877 | - include: interpolation 878 | - include: else-pop 879 | 880 | routines: 881 | - match: '(?:proc|func|method|template|macro|iterator|converter)\b' 882 | scope: storage.type.function.nim keyword.declaration.function.nim 883 | push: [routine-0, no-doc-comment] 884 | 885 | routine-0: 886 | - meta_scope: meta.function.nim 887 | - match: '{{symbol_lookahead}}' 888 | set: [routine-2, routine-1] 889 | - match: (?=\S) 890 | set: routine-3 891 | 892 | routine-1: 893 | - meta_content_scope: entity.name.function.nim 894 | - match: '\b(?:addr|type|static)\b' 895 | scope: 'keyword.nim' 896 | - match: '{{keyws}}' 897 | scope: invalid.illegal.nim 898 | - match: '{{symbol}}' 899 | - match: ' *(\*)' 900 | captures: 901 | 1: storage.modifier.nim 902 | pop: true 903 | - match: '' 904 | pop: true 905 | 906 | routine-2: 907 | - meta_content_scope: meta.function.nim 908 | - match: '\{(?!\.)' 909 | scope: punctuation.definition.pattern.begin.nim 910 | set: 911 | - meta_scope: meta.function.pattern.nim 912 | - match: '}' 913 | scope: punctuation.definition.pattern.end.nim 914 | set: routine-3 915 | - include: main 916 | - include: routine-3 917 | 918 | routine-3: 919 | - match: '\[' 920 | scope: punctuation.section.generic.begin.nim 921 | set: [routine-4, generic-param-list-0] 922 | - include: routine-4 923 | 924 | routine-4: 925 | - match: '\(' 926 | scope: meta.function.parameters.nim punctuation.section.parameters.begin.nim 927 | set: 928 | - meta_content_scope: meta.function.parameters.nim 929 | - match: '{{keyws}}' 930 | scope: invalid.illegal.nim 931 | pop: true 932 | - match: '{{symbol}}' 933 | scope: meta.function.parameters.nim variable.parameter.nim 934 | set: [routine-5, param-list, decl-col-eq-1] 935 | - match: '\)' 936 | scope: meta.function.parameters.nim punctuation.section.parameters.end.nim 937 | set: routine-5 938 | - match: '(?=\S)' 939 | set: routine-5 940 | - include: routine-5 941 | 942 | routine-5: 943 | - meta_content_scope: meta.function.nim 944 | - match: ':' 945 | scope: meta.function.nim punctuation.separator.annotation.return.nim 946 | pop: true 947 | - include: else-pop 948 | 949 | generic-param-list: 950 | - match: '\[' 951 | scope: punctuation.section.generic.begin.nim 952 | set: generic-param-list-0 953 | - include: else-pop 954 | 955 | generic-param-list-0: 956 | - meta_scope: meta.generic.nim 957 | - match: '{{keyws}}' 958 | scope: invalid.illegal.nim 959 | - match: '{{symbol}}' 960 | scope: variable.parameter.nim 961 | - match: '[,;]' 962 | scope: punctuation.separator.nim 963 | - match: '(:)|(=)' 964 | captures: 965 | 1: punctuation.separator.annotation 966 | 2: keyword.operator.assignment.nim 967 | push: generic-param-list-1 968 | - match: '\]' 969 | scope: punctuation.section.generic.end.nim 970 | pop: true 971 | - include: comments 972 | - include: else-pop 973 | 974 | generic-param-list-1: 975 | - match: '[,;]' 976 | scope: punctuation.separator.nim 977 | pop: true 978 | - match: '(?=\])' 979 | pop: true 980 | - include: main 981 | 982 | param-list: 983 | - meta_content_scope: meta.function.parameters.nim 984 | - clear_scopes: 1 985 | - match: '[,;]' 986 | scope: punctuation.separator.parameters.nim 987 | push: [decl-col-eq-0, comment] 988 | - match: '\)' 989 | scope: meta.function.parameters.nim punctuation.section.parameters.end.nim 990 | pop: true 991 | - include: else-pop 992 | 993 | decl-col-eq-0: 994 | - match: '{{keyws}}' 995 | scope: invalid.illegal.nim 996 | pop: true 997 | - match: '{{symbol}}' 998 | scope: variable.parameter.nim 999 | set: decl-col-eq-1 1000 | - include: else-pop 1001 | 1002 | decl-col-eq-1: 1003 | - match: '{{pragma_start}}' 1004 | scope: punctuation.definition.annotation.begin.nim 1005 | set: [decl-col-eq-2, pragma-1] 1006 | - match: ',' 1007 | scope: punctuation.separator.parameters.nim 1008 | set: [decl-col-eq-2, decl-col-eq-3, comment] 1009 | - match: ':' 1010 | scope: punctuation.separator.annotation.parameter.nim 1011 | set: decl-col-eq-4 1012 | - match: '=' 1013 | scope: keyword.operator.assignment.nim 1014 | set: decl-col-eq-4 1015 | - include: else-pop 1016 | 1017 | decl-col-eq-2: 1018 | - match: ',' 1019 | scope: punctuation.separator.parameters.nim 1020 | push: [decl-col-eq-3, comment] 1021 | - match: ':' 1022 | scope: punctuation.separator.annotation.parameter.nim 1023 | set: decl-col-eq-4 1024 | - match: '=' 1025 | scope: keyword.operator.assignment.nim 1026 | set: decl-col-eq-4 1027 | - include: else-pop 1028 | 1029 | decl-col-eq-3: 1030 | - match: '{{keyws}}' 1031 | scope: invalid.illegal.nim 1032 | pop: true 1033 | - match: '{{symbol}}' 1034 | scope: variable.parameter.nim 1035 | set: pragma-0 1036 | - match: '\S' 1037 | scope: invalid.illegal.nim 1038 | pop: true 1039 | 1040 | decl-col-eq-4: 1041 | - match: '(?=[,;\)])' 1042 | pop: true 1043 | - include: main 1044 | 1045 | pragmas: 1046 | - match: '{{pragma_start}}' 1047 | scope: punctuation.definition.annotation.begin.nim 1048 | push: pragma-1 1049 | 1050 | pragma-0: 1051 | - include: pragmas 1052 | - include: else-pop 1053 | 1054 | pragma-1: 1055 | - meta_scope: meta.annotation.nim 1056 | - match: '\.?}' 1057 | scope: punctuation.definition.annotation.end.nim 1058 | pop: true 1059 | - include: calls 1060 | - match: '{{symbol}}' 1061 | scope: entity.other.attribute-name.pragma.nim 1062 | - include: square-brackets 1063 | - match: (?=\S) 1064 | push: pragma-2 1065 | 1066 | pragma-2: 1067 | - match: ':' 1068 | scope: punctuation.separator.key-value.nim 1069 | set: 1070 | - match: '(?=\.?})' 1071 | pop: true 1072 | - match: ',' 1073 | scope: punctuation.separator.nim 1074 | pop: true 1075 | - include: main 1076 | - match: ',' 1077 | scope: punctuation.separator.nim 1078 | pop: true 1079 | - include: else-pop 1080 | 1081 | for-stmts: 1082 | - match: '\bfor\b' 1083 | scope: keyword.control.loop.for.nim 1084 | push: for-stmt-0 1085 | 1086 | for-stmt-0: 1087 | - match: \( 1088 | scope: punctuation.section.parens.begin.nim 1089 | set: 1090 | - match: \) 1091 | scope: punctuation.section.parens.end.nim 1092 | set: 1093 | - match: '\bin\b' 1094 | scope: keyword.control.loop.for.in.nim 1095 | pop: true 1096 | - include: else-pop 1097 | - include: for-stmt-1 1098 | - include: else-pop 1099 | - match: '\bin\b' 1100 | scope: keyword.control.loop.for.in.nim 1101 | pop: true 1102 | - include: for-stmt-1 1103 | - match: '(?=[^ ])' 1104 | pop: true 1105 | 1106 | for-stmt-1: 1107 | - match: ',' 1108 | scope: punctuation.separator.nim 1109 | - match: '{{symbol}}' 1110 | - include: pragmas 1111 | - include: comments 1112 | 1113 | operators: 1114 | - match: '\b(?:and|not|x?or)\b' 1115 | scope: keyword.operator.logical.nim 1116 | - match: ^of\b 1117 | scope: keyword.control.conditional.case.nim 1118 | - match: '\b(?:of|(?:not)?in|is(?:not)?)\b' 1119 | scope: keyword.operator.word.nim 1120 | - match: \bsh[lr]\b 1121 | scope: keyword.operator.bitwise.nim 1122 | - match: '\b(?:div|mod)\b' 1123 | scope: keyword.operator.arithmetic.nim 1124 | - match: '==|<=?|>=?|!=' 1125 | scope: keyword.operator.comparison.nim 1126 | - match: '(?:[[{{OPR}}]&&[^<>!=~?]][{{OPR}}]*)?=(?![{{OPR}}])' 1127 | scope: keyword.operator.assignment.nim 1128 | - match: '[{{OPR}}]+' 1129 | scope: keyword.operator.nim 1130 | -------------------------------------------------------------------------------- /Syntaxes/Nim.tmLanguage: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | fileTypes 6 | 7 | nim 8 | nims 9 | nimble 10 | 11 | name 12 | Nim 13 | patterns 14 | 15 | 16 | include 17 | #pragmas 18 | 19 | 20 | include 21 | #brackets 22 | 23 | 24 | include 25 | #punctuations 26 | 27 | 28 | include 29 | #block-doc-comments 30 | 31 | 32 | include 33 | #comments 34 | 35 | 36 | include 37 | #for-stmts 38 | 39 | 40 | include 41 | #asm-stmts 42 | 43 | 44 | include 45 | #routines 46 | 47 | 48 | include 49 | #fmt-strs 50 | 51 | 52 | include 53 | #operators 54 | 55 | 56 | include 57 | #literals 58 | 59 | 60 | include 61 | #keywords 62 | 63 | 64 | include 65 | #do-stmts 66 | 67 | 68 | include 69 | #calls 70 | 71 | 72 | include 73 | #types 74 | 75 | 76 | include 77 | #builtins 78 | 79 | 80 | include 81 | #generic-symbols 82 | 83 | 84 | repository 85 | 86 | asm-stmt-1 87 | 88 | patterns 89 | 90 | 91 | begin 92 | ([Rr])?(""") 93 | captures 94 | 95 | 1 96 | 97 | name 98 | storage.type.string.nim 99 | 100 | 2 101 | 102 | name 103 | string.quoted.triple.nim punctuation.definition.string.begin.nim 104 | 105 | 106 | contentName 107 | string.quoted.triple.nim 108 | end 109 | """(?!") 110 | endCaptures 111 | 112 | 0 113 | 114 | name 115 | string.quoted.triple.nim punctuation.definition.string.end.nim 116 | 117 | 118 | patterns 119 | 120 | 121 | include 122 | #interpolation 123 | 124 | 125 | 126 | 127 | begin 128 | ([Rr])(") 129 | beginCaptures 130 | 131 | 1 132 | 133 | name 134 | storage.type.string.nim 135 | 136 | 2 137 | 138 | name 139 | string.quoted.double.nim punctuation.definition.string.begin.nim 140 | 141 | 142 | contentName 143 | string.quoted.double.nim 144 | end 145 | (")|(\n) 146 | endCaptures 147 | 148 | 1 149 | 150 | name 151 | string.quoted.double.nim punctuation.definition.string.begin.nim 152 | 153 | 2 154 | 155 | name 156 | invalid.illegal.nim 157 | 158 | 159 | patterns 160 | 161 | 162 | include 163 | #interpolation 164 | 165 | 166 | 167 | 168 | begin 169 | " 170 | beginCaptures 171 | 172 | 0 173 | 174 | name 175 | punctuation.definition.string.begin.nim 176 | 177 | 178 | end 179 | (")|(\n) 180 | endCaptures 181 | 182 | 1 183 | 184 | name 185 | string.quoted.double.nim punctuation.definition.string.begin.nim 186 | 187 | 2 188 | 189 | name 190 | invalid.illegal.nim 191 | 192 | 193 | name 194 | string.quoted.double.nim 195 | patterns 196 | 197 | 198 | match 199 | \\(?:[ABCEFLNPRTVabceflnprtv"'\\]|\d+|[Xx]\h{2}|[Uu](?:\h{4}|\{\h+})) 200 | name 201 | constant.character.escape.nim 202 | 203 | 204 | match 205 | \\ 206 | name 207 | invalid.illegal.lone-escape.nim 208 | 209 | 210 | include 211 | #interpolation 212 | 213 | 214 | 215 | 216 | 217 | asm-stmts 218 | 219 | patterns 220 | 221 | 222 | begin 223 | asm\b 224 | beginCaptures 225 | 226 | 0 227 | 228 | name 229 | keyword.control.flow.nim 230 | 231 | 232 | end 233 | (?=[^"Rr{\s])|(?<=") 234 | patterns 235 | 236 | 237 | include 238 | #pragmas 239 | 240 | 241 | include 242 | #asm-stmt-1 243 | 244 | 245 | 246 | 247 | 248 | block-comments 249 | 250 | patterns 251 | 252 | 253 | begin 254 | #\[ 255 | beginCaptures 256 | 257 | 0 258 | 259 | name 260 | punctuation.definition.comment.begin.nim 261 | 262 | 263 | end 264 | ]# 265 | endCaptures 266 | 267 | 0 268 | 269 | name 270 | punctuation.definition.comment.end.nim 271 | 272 | 273 | name 274 | comment.block.number-sign.nim 275 | patterns 276 | 277 | 278 | include 279 | #block-comments 280 | 281 | 282 | 283 | 284 | 285 | block-doc-comments 286 | 287 | patterns 288 | 289 | 290 | begin 291 | ##\[ 292 | beginCaptures 293 | 294 | 0 295 | 296 | name 297 | punctuation.definition.comment.begin.nim 298 | 299 | 300 | end 301 | ]## 302 | endCaptures 303 | 304 | 0 305 | 306 | name 307 | punctuation.definition.comment.end.nim 308 | 309 | 310 | name 311 | comment.block.documentation.nim 312 | patterns 313 | 314 | 315 | include 316 | #block-doc-comments 317 | 318 | 319 | 320 | 321 | 322 | brackets 323 | 324 | patterns 325 | 326 | 327 | include 328 | #square-brackets 329 | 330 | 331 | begin 332 | \{ 333 | beginCaptures 334 | 335 | 0 336 | 337 | name 338 | punctuation.section.braces.begin.nim 339 | 340 | 341 | end 342 | } 343 | endCaptures 344 | 345 | 0 346 | 347 | name 348 | punctuation.section.braces.end.nim 349 | 350 | 351 | name 352 | meta.braces.nim 353 | patterns 354 | 355 | 356 | include 357 | $self 358 | 359 | 360 | 361 | 362 | begin 363 | \( 364 | beginCaptures 365 | 366 | 0 367 | 368 | name 369 | punctuation.section.parens.begin.nim 370 | 371 | 372 | end 373 | \) 374 | endCaptures 375 | 376 | 0 377 | 378 | name 379 | punctuation.section.parens.end.nim 380 | 381 | 382 | name 383 | meta.parens.nim 384 | patterns 385 | 386 | 387 | include 388 | $self 389 | 390 | 391 | 392 | 393 | 394 | builtins 395 | 396 | patterns 397 | 398 | 399 | match 400 | \bresult\b 401 | name 402 | variable.language.nim 403 | 404 | 405 | match 406 | \b(?x:any|array|auto|bool|byte |c(?:double|float|u?(?:long(?:long)?|char|int|short)|longdouble|schar |size(?:_t)?|string(?:[Aa]rray)?) |char|float(?:32|64)?|iterable|lent|open[Aa]rray|owned|pointer|ptr|range|ref|se[qt] |sink|static|string|typed?|type[Dd]esc|u?int(?:8|16|32|64)?|untyped|varargs|void)\b 407 | name 408 | storage.type.primitive.nim 409 | 410 | 411 | match 412 | \b(?x:appType|Compile(?:Date|Time)|cpuEndian |host(?:CPU|OS) |isMainModule|NaN|(?:Neg)?Inf|Nim(?:Major|Minor|Patch|Version)|nimvm|off|on |Quit(?:Failure|Success))\b 413 | name 414 | support.constant.builtin.nim 415 | 416 | 417 | 418 | calls 419 | 420 | patterns 421 | 422 | 423 | begin 424 | (?x: (?= (?: (?!(?:out|ptr|ref|tuple)\b) [A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])*|_|`[^;,\n`]+` ) (?:\[.*])? (?: \( |" |[ ]+ (?: [_\d"'`\[\(] |(?!\.|(?:\*?[ ]*)[:=]|=[^=])[-=+*/<>@$~&%|!?^.:\\∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]+[^\-=+*/<>@$~&%|!?^.:\\∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔\s] |(?!(as|asm|and|bind|break|concept|const|continue|converter |defer|discard|distinct|div|elif|else|end|except|export|finally|from|import |include|interface|is(?:not)?|let|macro|method|mixin|mod|(?:not)?in|of |raise|sh[lr]|template|using|while|yield|x?or)\b)[A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]] |\{(?!\.) ) ) ) ) 425 | end 426 | (?=[^\[\(`\w\x{80}-\x{ff}])|(?<=["\)]) 427 | patterns 428 | 429 | 430 | begin 431 | (?=[`_A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]]) 432 | end 433 | (?=[^`_A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]]) 434 | name 435 | entity.name.function.nim 436 | patterns 437 | 438 | 439 | include 440 | #builtins 441 | 442 | 443 | match 444 | [A-Z][\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]]+\b 445 | name 446 | support.type.nim 447 | 448 | 449 | match 450 | [A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])*|_|`[^;,\n`]+` 451 | 452 | 453 | 454 | 455 | begin 456 | \[:? 457 | beginCaptures 458 | 459 | 0 460 | 461 | name 462 | punctuation.section.generic.begin.nim 463 | 464 | 465 | end 466 | ] 467 | endCaptures 468 | 469 | 0 470 | 471 | name 472 | punctuation.section.generic.end.nim 473 | 474 | 475 | name 476 | meta.function-call.nim meta.generic.nim 477 | patterns 478 | 479 | 480 | include 481 | $self 482 | 483 | 484 | 485 | 486 | begin 487 | \( 488 | beginCaptures 489 | 490 | 0 491 | 492 | name 493 | punctuation.section.arguments.begin.nim 494 | 495 | 496 | end 497 | (\)) 498 | endCaptures 499 | 500 | 1 501 | 502 | name 503 | punctuation.section.arguments.end.nim 504 | 505 | 506 | name 507 | meta.function-call.arguments.nim 508 | patterns 509 | 510 | 511 | include 512 | $self 513 | 514 | 515 | 516 | 517 | include 518 | #triplestr_lit 519 | 520 | 521 | begin 522 | " 523 | beginCaptures 524 | 525 | 0 526 | 527 | name 528 | punctuation.definition.string.begin.nim 529 | 530 | 531 | end 532 | ("(?!"))|(\n) 533 | endCaptures 534 | 535 | 1 536 | 537 | name 538 | punctuation.definition.string.end.nim 539 | 540 | 2 541 | 542 | name 543 | invalid.illegal.unclosed-string.nim 544 | 545 | 546 | name 547 | string.quoted.double.nim 548 | patterns 549 | 550 | 551 | match 552 | "" 553 | name 554 | constant.character.escape.nim 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | characters 563 | 564 | patterns 565 | 566 | 567 | captures 568 | 569 | 0 570 | 571 | name 572 | constant.character.nim 573 | 574 | 1 575 | 576 | name 577 | constant.character.escape.nim 578 | 579 | 580 | match 581 | '(?:[^\\']|(\\(?:[ABCEFLNRTVabceflnrtv"'\\]|\d+|[Xx]\h{2})))' 582 | 583 | 584 | match 585 | '[^']+' 586 | name 587 | invalid.illegal.nim 588 | 589 | 590 | 591 | comments 592 | 593 | patterns 594 | 595 | 596 | include 597 | #block-comments 598 | 599 | 600 | include 601 | #line-comments 602 | 603 | 604 | 605 | do-stmts 606 | 607 | patterns 608 | 609 | 610 | begin 611 | \bdo\b 612 | beginCaptures 613 | 614 | 0 615 | 616 | name 617 | storage.type.function.nim 618 | 619 | 620 | end 621 | (->)|(?=[^\-\( ]) 622 | endCaptures 623 | 624 | 1 625 | 626 | name 627 | punctuation.separator.annotation.return.nim 628 | 629 | 630 | patterns 631 | 632 | 633 | include 634 | #param-list 635 | 636 | 637 | 638 | 639 | 640 | doc-comments 641 | 642 | patterns 643 | 644 | 645 | include 646 | #block-doc-comments 647 | 648 | 649 | include 650 | #line-doc-comments 651 | 652 | 653 | 654 | fmt-strs 655 | 656 | patterns 657 | 658 | 659 | begin 660 | (?:(fmt)|(&))(""") 661 | beginCaptures 662 | 663 | 1 664 | 665 | name 666 | meta.function-call.nim variable.function.nim 667 | 668 | 2 669 | 670 | name 671 | keyword.operator.nim 672 | 673 | 3 674 | 675 | name 676 | string.quoted.triple.nim punctuation.definition.string.begin.nim 677 | 678 | 679 | contentName 680 | string.quoted.triple.nim 681 | end 682 | """(?!") 683 | endCaptures 684 | 685 | 0 686 | 687 | name 688 | string.quoted.triple.nim punctuation.definition.string.end.nim 689 | 690 | 691 | patterns 692 | 693 | 694 | match 695 | {{|}} 696 | name 697 | constant.character.escape.nim 698 | 699 | 700 | begin 701 | { 702 | beginCaptures 703 | 704 | 0 705 | 706 | name 707 | punctuation.section.embedded.begin.nim 708 | 709 | 710 | end 711 | (=?(?: *:[^}]*)?) *(})|(?="""[^"]) 712 | endCaptures 713 | 714 | 1 715 | 716 | name 717 | constant.other.format-spec.nim 718 | 719 | 2 720 | 721 | name 722 | punctuation.section.embedded.end.nim 723 | 724 | 725 | name 726 | source.nim 727 | patterns 728 | 729 | 730 | include 731 | $self 732 | 733 | 734 | 735 | 736 | 737 | 738 | begin 739 | (fmt)(") 740 | beginCaptures 741 | 742 | 1 743 | 744 | name 745 | meta.function-call.nim variable.function.nim 746 | 747 | 2 748 | 749 | name 750 | string.quoted.double.nim punctuation.definition.string.begin.nim 751 | 752 | 753 | contentName 754 | string.quoted.triple.nim 755 | end 756 | ("(?!"))|(\n) 757 | endCaptures 758 | 759 | 1 760 | 761 | name 762 | string.quoted.double.nim punctuation.definition.string.end.nim 763 | 764 | 2 765 | 766 | name 767 | invalid.illegal.nim 768 | 769 | 770 | patterns 771 | 772 | 773 | match 774 | {{|}}|"" 775 | name 776 | constant.character.escape.nim 777 | 778 | 779 | begin 780 | { 781 | beginCaptures 782 | 783 | 0 784 | 785 | name 786 | punctuation.section.embedded.begin.nim 787 | 788 | 789 | end 790 | (=?(?: *:[^}]*)?) *(})|(\n)|(?=") 791 | endCaptures 792 | 793 | 1 794 | 795 | name 796 | constant.other.format-spec.nim 797 | 798 | 2 799 | 800 | name 801 | punctuation.section.embedded.end.nim 802 | 803 | 3 804 | 805 | name 806 | invalid.illegal.nim 807 | 808 | 809 | name 810 | source.nim 811 | patterns 812 | 813 | 814 | include 815 | $self 816 | 817 | 818 | 819 | 820 | 821 | 822 | begin 823 | (&)(") 824 | beginCaptures 825 | 826 | 1 827 | 828 | name 829 | keyword.operator.nim 830 | 831 | 2 832 | 833 | name 834 | string.quoted.double.nim punctuation.definition.string.begin.nim 835 | 836 | 837 | contentName 838 | string.quoted.double.nim 839 | end 840 | (")|(\n) 841 | endCaptures 842 | 843 | 1 844 | 845 | name 846 | string.quoted.double.nim punctuation.definition.string.end.nim 847 | 848 | 2 849 | 850 | name 851 | invalid.illegal.nim 852 | 853 | 854 | patterns 855 | 856 | 857 | match 858 | {{|}} 859 | name 860 | constant.character.escape.nim 861 | 862 | 863 | begin 864 | { 865 | beginCaptures 866 | 867 | 0 868 | 869 | name 870 | punctuation.section.embedded.begin.nim 871 | 872 | 873 | end 874 | (=?(?: *:[^}]*)?) *(})|(\n)|(?=") 875 | endCaptures 876 | 877 | 1 878 | 879 | name 880 | constant.other.format-spec.nim 881 | 882 | 2 883 | 884 | name 885 | punctuation.section.embedded.end.nim 886 | 887 | 3 888 | 889 | name 890 | invalid.illegal.nim 891 | 892 | 893 | name 894 | source.nim 895 | patterns 896 | 897 | 898 | match 899 | \\(?:[ABCEFLNPRTVabceflnprtv"'\\]|\d+|[Xx]\h{2}|[Uu](?:\h{4}|\{\h+})) 900 | name 901 | constant.character.escape.nim 902 | 903 | 904 | match 905 | \\ 906 | name 907 | invalid.illegal.lone-escape.nim 908 | 909 | 910 | include 911 | $self 912 | 913 | 914 | 915 | 916 | match 917 | \\(?:[ABCEFLNPRTVabceflnprtv"'\\]|\d+|[Xx]\h{2}|[Uu](?:\h{4}|\{\h+})) 918 | name 919 | constant.character.escape.nim 920 | 921 | 922 | match 923 | \\ 924 | name 925 | invalid.illegal.lone-escape.nim 926 | 927 | 928 | 929 | 930 | 931 | for-stmt-1 932 | 933 | patterns 934 | 935 | 936 | match 937 | , 938 | name 939 | punctuation.separator.nim 940 | 941 | 942 | match 943 | [A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])*|_|`[^;,\n`]+` 944 | 945 | 946 | include 947 | #pragmas 948 | 949 | 950 | include 951 | #comments 952 | 953 | 954 | 955 | for-stmts 956 | 957 | patterns 958 | 959 | 960 | begin 961 | for\b 962 | beginCaptures 963 | 964 | 0 965 | 966 | name 967 | keyword.control.loop.for.nim 968 | 969 | 970 | end 971 | (in\b)|(?=[^#,{_`A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]\s]) 972 | endCaptures 973 | 974 | 1 975 | 976 | name 977 | keyword.control.loop.for.in.nim 978 | 979 | 980 | patterns 981 | 982 | 983 | begin 984 | \( 985 | beginCaptures 986 | 987 | 0 988 | 989 | name 990 | punctuation.section.parens.begin.nim 991 | 992 | 993 | end 994 | (in\b)|(\))|(?=[^#,{_`A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]\s]) 995 | endCaptures 996 | 997 | 1 998 | 999 | name 1000 | keyword.control.loop.for.in.nim 1001 | 1002 | 2 1003 | 1004 | name 1005 | punctuation.section.parens.end.nim 1006 | 1007 | 1008 | patterns 1009 | 1010 | 1011 | include 1012 | #for-stmt-1 1013 | 1014 | 1015 | 1016 | 1017 | include 1018 | #for-stmt-1 1019 | 1020 | 1021 | 1022 | 1023 | 1024 | generic-param-list 1025 | 1026 | patterns 1027 | 1028 | 1029 | begin 1030 | (?<=[`*\w\x{80}-\x{ff}]) *(\[) 1031 | beginCaptures 1032 | 1033 | 1 1034 | 1035 | name 1036 | punctuation.section.generic.begin.nim 1037 | 1038 | 1039 | end 1040 | (])|(?=[^#_`:=,;A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]\s]) 1041 | endCaptures 1042 | 1043 | 1 1044 | 1045 | name 1046 | punctuation.section.generic.end.nim 1047 | 1048 | 1049 | name 1050 | meta.generic.nim 1051 | patterns 1052 | 1053 | 1054 | include 1055 | #generic-param-list-0 1056 | 1057 | 1058 | 1059 | 1060 | 1061 | generic-param-list-0 1062 | 1063 | patterns 1064 | 1065 | 1066 | match 1067 | [,;] 1068 | name 1069 | punctuation.separator.nim 1070 | 1071 | 1072 | begin 1073 | (:)|(=) 1074 | beginCaptures 1075 | 1076 | 1 1077 | 1078 | name 1079 | punctuation.separator.annotation.nim 1080 | 1081 | 2 1082 | 1083 | name 1084 | keyword.operator.assignment.nim 1085 | 1086 | 1087 | end 1088 | ([,;])|(?=\]) 1089 | endCaptures 1090 | 1091 | 1 1092 | 1093 | name 1094 | punctuation.separator.nim 1095 | 1096 | 1097 | patterns 1098 | 1099 | 1100 | include 1101 | $self 1102 | 1103 | 1104 | 1105 | 1106 | include 1107 | #comments 1108 | 1109 | 1110 | 1111 | generic-symbols 1112 | 1113 | patterns 1114 | 1115 | 1116 | match 1117 | [A-Z](_?[A-Z\d\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])+\b 1118 | name 1119 | support.constant.nim 1120 | 1121 | 1122 | match 1123 | [A-Z][\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]]+\b 1124 | name 1125 | support.type.nim 1126 | 1127 | 1128 | match 1129 | [A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])*|_|`[^;,\n`]+` 1130 | 1131 | 1132 | 1133 | interpolation 1134 | 1135 | patterns 1136 | 1137 | 1138 | captures 1139 | 1140 | 0 1141 | 1142 | name 1143 | source.nim.embedded 1144 | 1145 | 1 1146 | 1147 | name 1148 | punctuation.section.embedded.begin.nim 1149 | 1150 | 2 1151 | 1152 | name 1153 | punctuation.section.embedded.end.nim 1154 | 1155 | 1156 | match 1157 | (`) *(?:[A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])*|_) *(`) 1158 | 1159 | 1160 | 1161 | keywords 1162 | 1163 | patterns 1164 | 1165 | 1166 | match 1167 | \b(?:addr|cast)\b 1168 | name 1169 | keyword.operator.word.nim 1170 | 1171 | 1172 | begin 1173 | \bdiscard +""" 1174 | beginCaptures 1175 | 1176 | 0 1177 | 1178 | name 1179 | punctuation.definition.comment.begin.nim 1180 | 1181 | 1182 | end 1183 | """(?!") 1184 | endCaptures 1185 | 1186 | 0 1187 | 1188 | name 1189 | punctuation.definition.comment.end.nim 1190 | 1191 | 1192 | name 1193 | comment.block.nim 1194 | 1195 | 1196 | match 1197 | \b(?:distinct|discard)\b 1198 | name 1199 | keyword.other.nim 1200 | 1201 | 1202 | match 1203 | \b(?:asm|end|break|continue|raise|return|yield)\b 1204 | name 1205 | keyword.control.flow.nim 1206 | 1207 | 1208 | match 1209 | \b(?:concept|enum|interface)\b 1210 | name 1211 | storage.type.nim 1212 | 1213 | 1214 | captures 1215 | 1216 | 1 1217 | 1218 | name 1219 | storage.type.nim 1220 | 1221 | 2 1222 | 1223 | name 1224 | keyword.other.nim 1225 | 1226 | 1227 | match 1228 | \b(object)\b(?: *(of)\b)? 1229 | 1230 | 1231 | match 1232 | \bwhile\b 1233 | name 1234 | keyword.control.loop.while.nim 1235 | 1236 | 1237 | match 1238 | \bcase\b 1239 | name 1240 | keyword.control.conditional.switch.nim 1241 | 1242 | 1243 | match 1244 | ^ *(of)\b 1245 | name 1246 | keyword.control.conditional.case.nim 1247 | 1248 | 1249 | match 1250 | \bif\b 1251 | name 1252 | keyword.control.conditional.if.nim 1253 | 1254 | 1255 | match 1256 | \bwhen\b 1257 | name 1258 | keyword.control.conditional.when.nim 1259 | 1260 | 1261 | match 1262 | \belif\b 1263 | name 1264 | keyword.control.conditional.elseif.nim 1265 | 1266 | 1267 | captures 1268 | 1269 | 0 1270 | 1271 | name 1272 | meta.statement.conditional.else.nim 1273 | 1274 | 1 1275 | 1276 | name 1277 | keyword.control.conditional.else.nim 1278 | 1279 | 2 1280 | 1281 | name 1282 | punctuation.section.block.conditional.else.nim 1283 | 1284 | 1285 | match 1286 | \b(else)\b(?: *(:))? 1287 | 1288 | 1289 | captures 1290 | 1291 | 0 1292 | 1293 | name 1294 | meta.statement.exception.try.nim 1295 | 1296 | 1 1297 | 1298 | name 1299 | keyword.control.exception.try.nim 1300 | 1301 | 2 1302 | 1303 | name 1304 | punctuation.section.block.exception.nim 1305 | 1306 | 1307 | match 1308 | \b(try)\b(?: *(:))? 1309 | 1310 | 1311 | captures 1312 | 1313 | 0 1314 | 1315 | name 1316 | meta.statement.exception.finally.nim 1317 | 1318 | 1 1319 | 1320 | name 1321 | keyword.control.exception.finally.nim 1322 | 1323 | 2 1324 | 1325 | name 1326 | punctuation.section.block.exception.finally.nim 1327 | 1328 | 1329 | match 1330 | \b(finally)\b(?: *(:))? 1331 | 1332 | 1333 | captures 1334 | 1335 | 1 1336 | 1337 | name 1338 | keyword.control.flow.defer.nim 1339 | 1340 | 2 1341 | 1342 | name 1343 | punctuation.section.block.begin.nim 1344 | 1345 | 1346 | match 1347 | \b(defer)\b(?: *(:))? 1348 | 1349 | 1350 | captures 1351 | 1352 | 1 1353 | 1354 | name 1355 | keyword.declaration.block.nim 1356 | 1357 | 2 1358 | 1359 | name 1360 | punctuation.section.block.begin.nim 1361 | 1362 | 1363 | match 1364 | \b(block)\b(?:(?: *(?:[A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])*|_|`[^;,\n`]+`))? *(:))? 1365 | 1366 | 1367 | match 1368 | \b(?:as|(?:ex|im)port|include|bind|mixin|from|except)\b 1369 | name 1370 | keyword.control.nim 1371 | 1372 | 1373 | match 1374 | \b(?:const|let|var|using)\b 1375 | name 1376 | storage.modifier.nim 1377 | 1378 | 1379 | 1380 | language-constants 1381 | 1382 | patterns 1383 | 1384 | 1385 | match 1386 | \b(?:true|false|nil)\b 1387 | name 1388 | constant.language.nim 1389 | 1390 | 1391 | 1392 | line-comments 1393 | 1394 | patterns 1395 | 1396 | 1397 | begin 1398 | (#)(?: *(TODO|todo)\b)? 1399 | beginCaptures 1400 | 1401 | 1 1402 | 1403 | name 1404 | punctuation.definition.comment.nim 1405 | 1406 | 2 1407 | 1408 | name 1409 | invalid.deprecated.nim 1410 | 1411 | 1412 | end 1413 | $\n? 1414 | name 1415 | comment.line.number-sign.nim 1416 | 1417 | 1418 | 1419 | line-doc-comments 1420 | 1421 | patterns 1422 | 1423 | 1424 | begin 1425 | ## 1426 | beginCaptures 1427 | 1428 | 0 1429 | 1430 | name 1431 | punctuation.definition.comment.nim 1432 | 1433 | 1434 | end 1435 | $\n? 1436 | name 1437 | comment.line.documentation.nim 1438 | 1439 | 1440 | 1441 | literals 1442 | 1443 | patterns 1444 | 1445 | 1446 | include 1447 | #str_lits 1448 | 1449 | 1450 | include 1451 | #numbers 1452 | 1453 | 1454 | include 1455 | #characters 1456 | 1457 | 1458 | include 1459 | #language-constants 1460 | 1461 | 1462 | 1463 | numbers 1464 | 1465 | patterns 1466 | 1467 | 1468 | captures 1469 | 1470 | 0 1471 | 1472 | name 1473 | meta.number.float.decimal.nim 1474 | 1475 | 1 1476 | 1477 | name 1478 | constant.numeric.value.nim 1479 | 1480 | 2 1481 | 1482 | name 1483 | constant.numeric.value.nim 1484 | 1485 | 3 1486 | 1487 | name 1488 | punctuation.separator.decimal.nim 1489 | 1490 | 4 1491 | 1492 | name 1493 | constant.numeric.value.exponent.nim 1494 | 1495 | 5 1496 | 1497 | name 1498 | constant.numeric.value.exponent.nim 1499 | 1500 | 6 1501 | 1502 | name 1503 | constant.numeric.suffix.nim 1504 | 1505 | 7 1506 | 1507 | name 1508 | constant.numeric.suffix.nim 1509 | 1510 | 1511 | match 1512 | (?x: \b(\d(?:_?\d)*) (?: (?: ((\.)\d(?:_?\d)*) ([Ee][-+]?\d(?:_?\d)*)? |([Ee][-+]?\d(?:_?\d)*) ) ('(?:[A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])*|_)|(?:[Ff](?:32|64)|[Dd]))? |('(?:[A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])*|_)|(?:[Ff](?:32|64)|[Dd])) ) ) 1513 | 1514 | 1515 | captures 1516 | 1517 | 0 1518 | 1519 | name 1520 | meta.number.float.hexadecimal.nim 1521 | 1522 | 1 1523 | 1524 | name 1525 | constant.numeric.base.nim 1526 | 1527 | 2 1528 | 1529 | name 1530 | constant.numeric.value.nim 1531 | 1532 | 3 1533 | 1534 | name 1535 | constant.numeric.suffix.nim 1536 | 1537 | 1538 | match 1539 | (?x: \b(0[Xx]) (\h(?:_?\h)*) ('(?:[A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])*|_)|[Ff](?:32|64)) ) 1540 | 1541 | 1542 | captures 1543 | 1544 | 0 1545 | 1546 | name 1547 | meta.number.float.octal.nim 1548 | 1549 | 1 1550 | 1551 | name 1552 | constant.numeric.base.nim 1553 | 1554 | 2 1555 | 1556 | name 1557 | constant.numeric.value.nim 1558 | 1559 | 3 1560 | 1561 | name 1562 | constant.numeric.suffix.nim 1563 | 1564 | 1565 | match 1566 | (?x: \b(0o) ([0-7](?:_?[0-7])*) ('(?:[A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])*|_)|(?:[Ff](?:32|64)|[Dd])) ) 1567 | 1568 | 1569 | captures 1570 | 1571 | 0 1572 | 1573 | name 1574 | meta.number.float.binary.nim 1575 | 1576 | 1 1577 | 1578 | name 1579 | constant.numeric.base.nim 1580 | 1581 | 2 1582 | 1583 | name 1584 | constant.numeric.value.nim 1585 | 1586 | 3 1587 | 1588 | name 1589 | constant.numeric.suffix.nim 1590 | 1591 | 1592 | match 1593 | (?x: \b(0[Bb]) ([01](?:_?[01])*) ('(?:[A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])*|_)|(?:[Ff](?:32|64)|[Dd])) ) 1594 | 1595 | 1596 | captures 1597 | 1598 | 0 1599 | 1600 | name 1601 | meta.number.integer.hexadecimal.nim 1602 | 1603 | 1 1604 | 1605 | name 1606 | constant.numeric.base.nim 1607 | 1608 | 2 1609 | 1610 | name 1611 | constant.numeric.value.nim 1612 | 1613 | 3 1614 | 1615 | name 1616 | constant.numeric.suffix.nim 1617 | 1618 | 1619 | match 1620 | (?x: \b(0[Xx]) (\h(?:_?\h)*) ('(?:[A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])*|_)|(?:[IUiu](?:8|16|32|64)|[Uu]))? ) 1621 | 1622 | 1623 | captures 1624 | 1625 | 0 1626 | 1627 | name 1628 | meta.number.integer.octal.nim 1629 | 1630 | 1 1631 | 1632 | name 1633 | constant.numeric.base.nim 1634 | 1635 | 2 1636 | 1637 | name 1638 | constant.numeric.value.nim 1639 | 1640 | 3 1641 | 1642 | name 1643 | constant.numeric.suffix.nim 1644 | 1645 | 1646 | match 1647 | (?x: \b(0o) ([0-7](?:_?[0-7])*) ('(?:[A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])*|_)|(?:[IUiu](?:8|16|32|64)|[Uu]))? ) 1648 | 1649 | 1650 | captures 1651 | 1652 | 0 1653 | 1654 | name 1655 | meta.number.integer.binary.nim 1656 | 1657 | 1 1658 | 1659 | name 1660 | constant.numeric.base.nim 1661 | 1662 | 2 1663 | 1664 | name 1665 | constant.numeric.value.nim 1666 | 1667 | 3 1668 | 1669 | name 1670 | constant.numeric.suffix.nim 1671 | 1672 | 1673 | match 1674 | (?x: \b(0[Bb]) ([01](?:_?[01])*) ('(?:[A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])*|_)|(?:[IUiu](?:8|16|32|64)|[Uu]))? ) 1675 | 1676 | 1677 | captures 1678 | 1679 | 0 1680 | 1681 | name 1682 | meta.number.integer.decimal.nim 1683 | 1684 | 1 1685 | 1686 | name 1687 | constant.numeric.value.nim 1688 | 1689 | 2 1690 | 1691 | name 1692 | constant.numeric.suffix.nim 1693 | 1694 | 1695 | match 1696 | (?x: \b(\d(?:_?\d)*) ('(?:[A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])*|_)|(?:[IUiu](?:8|16|32|64)|[Uu]))? ) 1697 | 1698 | 1699 | 1700 | operators 1701 | 1702 | patterns 1703 | 1704 | 1705 | match 1706 | \b(?:and|not|x?or)\b 1707 | name 1708 | keyword.operator.logical.nim 1709 | 1710 | 1711 | match 1712 | ^of\b 1713 | name 1714 | keyword.control.conditional.case.nim 1715 | 1716 | 1717 | match 1718 | \b(?:of|(?:not)?in|is(?:not)?)\b 1719 | name 1720 | keyword.operator.word.nim 1721 | 1722 | 1723 | match 1724 | \bsh[lr]\b 1725 | name 1726 | keyword.operator.bitwise.nim 1727 | 1728 | 1729 | match 1730 | \b(?:div|mod)\b 1731 | name 1732 | keyword.operator.arithmetic.nim 1733 | 1734 | 1735 | match 1736 | ==|<=?|>=?|!= 1737 | name 1738 | keyword.operator.comparison.nim 1739 | 1740 | 1741 | match 1742 | (?:[-+*/@$&%|^.:\\∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔][-=+*/<>@$~&%|!?^.:\\∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]*)?=(?![-=+*/<>@$~&%|!?^.:\\∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]) 1743 | name 1744 | keyword.operator.assignment.nim 1745 | 1746 | 1747 | match 1748 | [-=+*/<>@$~&%|!?^.:\\∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]+ 1749 | name 1750 | keyword.operator.nim 1751 | 1752 | 1753 | 1754 | param-list 1755 | 1756 | patterns 1757 | 1758 | 1759 | begin 1760 | \( 1761 | beginCaptures 1762 | 1763 | 0 1764 | 1765 | name 1766 | punctuation.section.parameters.begin.nim 1767 | 1768 | 1769 | end 1770 | \) 1771 | endCaptures 1772 | 1773 | 0 1774 | 1775 | name 1776 | punctuation.section.parameters.end.nim 1777 | 1778 | 1779 | name 1780 | meta.function.parameters 1781 | patterns 1782 | 1783 | 1784 | match 1785 | [,;] 1786 | name 1787 | punctuation.separator.nim 1788 | 1789 | 1790 | begin 1791 | (:)|(=) 1792 | beginCaptures 1793 | 1794 | 1 1795 | 1796 | name 1797 | punctuation.separator.annotation.nim 1798 | 1799 | 2 1800 | 1801 | name 1802 | keyword.operator.assignment.nim 1803 | 1804 | 1805 | end 1806 | (?=[,;\)]) 1807 | patterns 1808 | 1809 | 1810 | include 1811 | $self 1812 | 1813 | 1814 | 1815 | 1816 | include 1817 | #comments 1818 | 1819 | 1820 | 1821 | 1822 | 1823 | patterns 1824 | 1825 | patterns 1826 | 1827 | 1828 | begin 1829 | \{(?!\.) 1830 | beginCaptures 1831 | 1832 | 0 1833 | 1834 | name 1835 | punctuation.section.pattern.begin.nim 1836 | 1837 | 1838 | end 1839 | } 1840 | endCaptures 1841 | 1842 | 0 1843 | 1844 | name 1845 | punctuation.section.pattern.end.nim 1846 | 1847 | 1848 | name 1849 | meta.pattern.nim 1850 | patterns 1851 | 1852 | 1853 | include 1854 | $self 1855 | 1856 | 1857 | 1858 | 1859 | 1860 | pragmas 1861 | 1862 | patterns 1863 | 1864 | 1865 | begin 1866 | \{\.(?!\.}) 1867 | beginCaptures 1868 | 1869 | 0 1870 | 1871 | name 1872 | punctuation.section.annotation.begin.nim 1873 | 1874 | 1875 | end 1876 | \.?} 1877 | endCaptures 1878 | 1879 | 0 1880 | 1881 | name 1882 | punctuation.section.annotation.end.nim 1883 | 1884 | 1885 | name 1886 | meta.annotation.nim 1887 | patterns 1888 | 1889 | 1890 | include 1891 | #calls 1892 | 1893 | 1894 | match 1895 | [A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])*|_|`[^;,\n`]+` 1896 | name 1897 | entity.other.attribute-name.pragma.nim 1898 | 1899 | 1900 | include 1901 | #square-brackets 1902 | 1903 | 1904 | begin 1905 | (?=\S) 1906 | end 1907 | (,)|(?=\.?}) 1908 | endCaptures 1909 | 1910 | 1 1911 | 1912 | name 1913 | punctuation.separator.sequence.nim 1914 | 1915 | 1916 | patterns 1917 | 1918 | 1919 | begin 1920 | : 1921 | beginCaptures 1922 | 1923 | 0 1924 | 1925 | name 1926 | punctuation.separator.key-value.nim 1927 | 1928 | 1929 | end 1930 | (?=,|\.?}) 1931 | patterns 1932 | 1933 | 1934 | include 1935 | $self 1936 | 1937 | 1938 | 1939 | 1940 | 1941 | 1942 | 1943 | 1944 | 1945 | punctuations 1946 | 1947 | patterns 1948 | 1949 | 1950 | match 1951 | ; 1952 | name 1953 | punctuation.terminator.statement.nim 1954 | 1955 | 1956 | match 1957 | , 1958 | name 1959 | punctuation.separator.nim 1960 | 1961 | 1962 | match 1963 | : 1964 | name 1965 | punctuation.section.block.begin.nim 1966 | 1967 | 1968 | match 1969 | \.(?![-=+*/<>@$~&%|!?^.:\\∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]) 1970 | name 1971 | punctuation.accessor.dot.nim 1972 | 1973 | 1974 | captures 1975 | 1976 | 1 1977 | 1978 | name 1979 | storage.modifier.nim 1980 | 1981 | 2 1982 | 1983 | name 1984 | punctuation.separator.annotation.nim 1985 | 1986 | 1987 | match 1988 | (\*) *(:|(?=,|#|\{\.)) 1989 | 1990 | 1991 | match 1992 | \)|]|} 1993 | name 1994 | invalid.illegal.nim 1995 | 1996 | 1997 | 1998 | routines 1999 | 2000 | patterns 2001 | 2002 | 2003 | begin 2004 | (?x: (proc|template|iterator|func|method|macro|converter)\b (?:[ ]*([A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]])*|_|`[^;,\n`]+`)(?:[ ]*(\*))?)? ) 2005 | beginCaptures 2006 | 2007 | 1 2008 | 2009 | name 2010 | storage.type.function.nim 2011 | 2012 | 2 2013 | 2014 | name 2015 | entity.name.function.nim 2016 | 2017 | 3 2018 | 2019 | name 2020 | storage.modifier.nim 2021 | 2022 | 2023 | end 2024 | (:)|(?=[^#\(\[:\s]|##) 2025 | endCaptures 2026 | 2027 | 1 2028 | 2029 | name 2030 | punctuation.separator.annotation.nim 2031 | 2032 | 2033 | name 2034 | meta.function.nim 2035 | patterns 2036 | 2037 | 2038 | include 2039 | #comments 2040 | 2041 | 2042 | include 2043 | #patterns 2044 | 2045 | 2046 | include 2047 | #generic-param-list 2048 | 2049 | 2050 | include 2051 | #param-list 2052 | 2053 | 2054 | 2055 | 2056 | 2057 | rstr_lit 2058 | 2059 | patterns 2060 | 2061 | 2062 | begin 2063 | ([Rr])(") 2064 | beginCaptures 2065 | 2066 | 1 2067 | 2068 | name 2069 | storage.type.nim 2070 | 2071 | 2 2072 | 2073 | name 2074 | string.quoted.double.nim punctuation.definition.string.begin.nim 2075 | 2076 | 2077 | contentName 2078 | string.quoted.double.nim 2079 | end 2080 | ("(?!"))|(\n) 2081 | endCaptures 2082 | 2083 | 1 2084 | 2085 | name 2086 | string.quoted.double.nim punctuation.definition.string.end.nim 2087 | 2088 | 2 2089 | 2090 | name 2091 | string.quoted.double.nim invalid.illegal.unclosed-string.nim 2092 | 2093 | 2094 | patterns 2095 | 2096 | 2097 | match 2098 | "" 2099 | name 2100 | constant.character.escape.nim 2101 | 2102 | 2103 | 2104 | 2105 | 2106 | square-brackets 2107 | 2108 | patterns 2109 | 2110 | 2111 | begin 2112 | \[ 2113 | beginCaptures 2114 | 2115 | 0 2116 | 2117 | name 2118 | punctuation.section.brackets.begin.nim 2119 | 2120 | 2121 | end 2122 | ] 2123 | endCaptures 2124 | 2125 | 0 2126 | 2127 | name 2128 | punctuation.section.brackets.end.nim 2129 | 2130 | 2131 | name 2132 | meta.brackets.nim 2133 | patterns 2134 | 2135 | 2136 | include 2137 | $self 2138 | 2139 | 2140 | 2141 | 2142 | 2143 | str_lit 2144 | 2145 | patterns 2146 | 2147 | 2148 | begin 2149 | " 2150 | beginCaptures 2151 | 2152 | 0 2153 | 2154 | name 2155 | punctuation.definition.string.begin.nim 2156 | 2157 | 2158 | end 2159 | (")|(\n) 2160 | endCaptures 2161 | 2162 | 1 2163 | 2164 | name 2165 | punctuation.definition.string.end.nim 2166 | 2167 | 2 2168 | 2169 | name 2170 | invalid.illegal.nim 2171 | 2172 | 2173 | name 2174 | string.quoted.double.nim 2175 | patterns 2176 | 2177 | 2178 | match 2179 | \\(?:[ABCEFLNPRTVabceflnprtv"'\\]|\d+|[Xx]\h{2}|[Uu](?:\h{4}|\{\h+})) 2180 | name 2181 | constant.character.escape.nim 2182 | 2183 | 2184 | match 2185 | \\ 2186 | name 2187 | invalid.illegal.lone-escape.nim 2188 | 2189 | 2190 | 2191 | 2192 | 2193 | str_lits 2194 | 2195 | patterns 2196 | 2197 | 2198 | include 2199 | #triplestr_lit 2200 | 2201 | 2202 | include 2203 | #rstr_lit 2204 | 2205 | 2206 | include 2207 | #str_lit 2208 | 2209 | 2210 | 2211 | triplestr_lit 2212 | 2213 | patterns 2214 | 2215 | 2216 | begin 2217 | ([Rr])?(""") 2218 | beginCaptures 2219 | 2220 | 1 2221 | 2222 | name 2223 | storage.type.nim 2224 | 2225 | 2 2226 | 2227 | name 2228 | string.quoted.triple.nim punctuation.definition.string.begin.nim 2229 | 2230 | 2231 | contentName 2232 | string.quoted.triple.nim 2233 | end 2234 | """(?!") 2235 | endCaptures 2236 | 2237 | 0 2238 | 2239 | name 2240 | string.quoted.triple.nim punctuation.definition.string.end.nim 2241 | 2242 | 2243 | 2244 | 2245 | 2246 | types 2247 | 2248 | patterns 2249 | 2250 | 2251 | begin 2252 | (?=(?:[A-Za-z\x80-\x{10FFFF}&&[^∙∘×★⊗⊘⊙⊛⊠⊡∩∧⊓±⊕⊖⊞⊟∪∨⊔]](?:_?[\dA-Za-z])*)\[)(?x:(out|ptr|ref|array |cstring[Aa]rray|iterable|lent|open[Aa]rray|owned|ptr|range|ref|se[qt] |sink|static|type(?:[Dd]esc)?|varargs)|([A-Z][\dA-Za-z]+))(\[) 2253 | beginCaptures 2254 | 2255 | 1 2256 | 2257 | name 2258 | storage.type.primitive.nim 2259 | 2260 | 2 2261 | 2262 | name 2263 | support.type.nim 2264 | 2265 | 3 2266 | 2267 | name 2268 | meta.generic.nim punctuation.section.generic.begin.nim 2269 | 2270 | 2271 | contentName 2272 | meta.generic.nim 2273 | end 2274 | ] 2275 | endCaptures 2276 | 2277 | 0 2278 | 2279 | name 2280 | meta.generic.nim punctuation.section.generic.nim 2281 | 2282 | 2283 | patterns 2284 | 2285 | 2286 | include 2287 | $self 2288 | 2289 | 2290 | 2291 | 2292 | match 2293 | \b(?:out|tuple|ref|ptr)\b 2294 | name 2295 | storage.type.primitive.nim 2296 | 2297 | 2298 | 2299 | 2300 | scopeName 2301 | source.nim 2302 | 2303 | 2304 | -------------------------------------------------------------------------------- /Syntaxes/syntax_test.nim: -------------------------------------------------------------------------------- 1 | # SYNTAX TEST "Packages/Nim/Syntaxes/Nim.sublime-syntax" 2 | # <- source.nim comment.line.number-sign punctuation.definition.comment 3 | 4 | discard """ 5 | #^^^^^^^^^^ comment.block.nim punctuation.definition.comment.begin.nim 6 | """ 7 | 8 | #[ 9 | multi-line comment 10 | #[ 11 | nested comment 12 | ]# 13 | ]# 14 | 15 | proc f = 16 | ## doc comment 17 | # ^^ comment.line.documentation.nim punctuation.definition.comment.nim 18 | ##[ 19 | # ^^^ comment.block.documentation.nim punctuation.definition.comment.begin.nim 20 | multi-line doc comment 21 | ##[ 22 | # ^^^ comment.block.documentation.nim comment.block.documentation.nim punctuation.definition.comment.begin.nim 23 | can be nested too 24 | ]## 25 | # ^^^ comment.block.documentation.nim comment.block.documentation.nim punctuation.definition.comment.end.nim 26 | ]## 27 | # ^^^ comment.block.documentation.nim punctuation.definition.comment.end.nim 28 | 29 | # Literals 30 | ########## 31 | 32 | "Escape chars\: \'\n, \N, \x420, \u45328 or \u{90211234}\"" 33 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.nim string.quoted.double.nim 34 | #^ punctuation.definition.string.begin.nim 35 | # ^ invalid.illegal.lone-escape.nim 36 | # ^^ constant.character.escape.nim 37 | # ^^ constant.character.escape.nim 38 | # ^^ constant.character.escape.nim 39 | # ^^^^ constant.character.escape.nim 40 | # ^^^^^^ constant.character.escape.nim 41 | # ^^^^^^^^^^^^ constant.character.escape.nim 42 | # ^^ constant.character.escape.nim 43 | # ^ punctuation.definition.string.end.nim 44 | "unclosed 45 | #^^^^^^^^^ meta.string.nim string.quoted.double.nim 46 | #^ punctuation.definition.string.begin.nim 47 | # ^ meta.string.nim string.quoted.double.nim invalid.illegal.nim 48 | r"raw string \Li\teral ""\x23""" 49 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.nim 50 | # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double.nim 51 | # ^ punctuation.definition.string.begin.nim 52 | # ^^ constant.character.escape.double-quote.nim 53 | # ^ punctuation.definition.string.end.nim 54 | """ 55 | #^^^ meta.string.nim string.quoted.double.block.nim punctuation.definition.string.begin.nim 56 | Multi-line string \t \x21 "" 57 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.nim string.quoted.double.block.nim 58 | """""" 59 | #^^^^^^ meta.string.nim string.quoted.double.block.nim 60 | # ^^^ punctuation.definition.string.end.nim 61 | R"""" 62 | #^^^^^ meta.string.nim 63 | #^ storage.type.string.nim 64 | # ^^^ string.quoted.double.block.nim punctuation.definition.string.begin.nim 65 | Identical to normal multi-line string 66 | """" 67 | #^^^^ meta.string.nim string.quoted.double.block.nim 68 | # ^^^ punctuation.definition.string.end.nim 69 | 70 | 71 | 'm' 72 | #^^^ constant.character.nim 73 | '\x12' 74 | #^^^^^^ constant.character.nim 75 | # ^^^^ constant.character.escape.nim 76 | '\n' 77 | # ^^ constant.character.escape.nim 78 | '\L' 79 | # ^^ constant.character.escape.nim 80 | '\"' 81 | # ^^ constant.character.escape.nim 82 | '\' 83 | #^^^ invalid.illegal.nim 84 | 'chars' 85 | #^^^^^^^ invalid.illegal.nim 86 | 87 | 1 88 | #^ meta.number.integer.decimal.nim constant.numeric.value.nim 89 | 1.2 90 | #^^^ meta.number.float.decimal.nim constant.numeric.value.nim 91 | # ^ punctuation.separator.decimal.nim 92 | 1.2e2 93 | #^^^^^ meta.number.float.decimal.nim 94 | #^^^ constant.numeric.value.nim 95 | # ^ punctuation.separator.decimal.nim 96 | # ^^ constant.numeric.value.exponent.nim 97 | -1.205f64 98 | #^ keyword.operator.nim 99 | # ^^^^^^^^ meta.number.float.decimal.nim 100 | # ^^^^^ constant.numeric.value.nim 101 | # ^ punctuation.separator.decimal.nim 102 | # ^^^ constant.numeric.suffix.nim 103 | 1.2E-10'f32 104 | #^^^^^^^^^^^ meta.number.float.decimal.nim 105 | #^^^ constant.numeric.value.nim 106 | # ^ punctuation.separator.decimal.nim 107 | # ^^^^ constant.numeric.value.exponent.nim 108 | # ^^^^ constant.numeric.suffix.nim 109 | 0b1'u32 110 | #^^^^^^^ meta.number.float.binary.nim 111 | #^^ constant.numeric.base.nim 112 | # ^ constant.numeric.value.nim 113 | # ^^^^ constant.numeric.suffix.nim 114 | 0xf32f32 115 | #^^^^^^^^ meta.number.float.hexadecimal.nim 116 | #^^ constant.numeric.base.nim 117 | # ^^^ constant.numeric.value.nim 118 | # ^^^ constant.numeric.suffix.nim 119 | 0o7210'big 120 | #^^^^^^^^^^ meta.number.float.octal.nim 121 | #^^ constant.numeric.base.nim 122 | # ^^^^ constant.numeric.value.nim 123 | # ^^^^ constant.numeric.suffix.nim 124 | 0o7210big 125 | #^^^^^^ meta.number.integer.octal.nim 126 | #^^ constant.numeric.base.nim 127 | # ^^^^ constant.numeric.value.nim 128 | 0.9*a 129 | #^^^ meta.number.float.decimal.nim constant.numeric.value.nim 130 | # ^ punctuation.separator.decimal.nim 131 | # ^ keyword.operator.nim 132 | 0xDEADBEEF 133 | #^^^^^^^^^^ meta.number.integer.hexadecimal.nim 134 | #^^ constant.numeric.base.nim 135 | # ^^^^^^^^ constant.numeric.value.nim 136 | 137 | const c = false 138 | #^^^^ storage.modifier.nim keyword.declaration.constant.nim 139 | # ^ entity.name.constant.nim 140 | # ^ keyword.operator.assignment.nim 141 | # ^^^^^ constant.language.nim 142 | const (c1*, c2) = (m, not a) 143 | #^^^^ storage.modifier.nim keyword.declaration.constant.nim 144 | # ^ punctuation.section.parens.begin.nim 145 | # ^^ entity.name.constant.nim 146 | # ^ storage.modifier.nim 147 | # ^ punctuation.separator.nim 148 | # ^^ entity.name.constant.nim 149 | # ^ punctuation.section.parens.end.nim 150 | # ^ keyword.operator.assignment.nim 151 | # ^ punctuation.section.parens.begin.nim 152 | # ^ punctuation.separator.nim 153 | # ^^^ keyword.operator.logical.nim 154 | # ^ punctuation.section.parens.end.nim 155 | const 156 | #^^ storage.modifier.nim keyword.declaration.constant.nim 157 | π*: float32 = 3.14 158 | #<- entity.name.constant.nim 159 | #^ storage.modifier.nim 160 | # ^ punctuation.separator.annotation.nim 161 | # ^^^^^^^ storage.type.primitive.nim 162 | abc {.pr} = 5 163 | #^^ entity.name.constant.nim 164 | # ^^^^^ meta.annotation.nim 165 | # ^^ punctuation.definition.annotation.begin.nim 166 | # ^^ entity.other.attribute-name.pragma.nim 167 | # ^ punctuation.definition.annotation.end.nim 168 | 169 | abc, d = 170 | #^^ entity.name.constant.nim 171 | # ^ invalid.illegal.nim 172 | (abc, d) = 173 | #<- punctuation.section.parens.begin.nim 174 | #^^^ entity.name.constant.nim 175 | # ^ punctuation.separator.nim 176 | # ^ entity.name.constant.nim 177 | # ^ punctuation.section.parens.end.nim 178 | (def {.m}, ): 179 | #<- punctuation.section.parens.begin.nim 180 | #^^^ entity.name.constant.nim 181 | # ^^^^ meta.annotation.nim 182 | # ^ punctuation.separator.nim 183 | # ^ punctuation.section.parens.end.nim 184 | # ^ invalid.illegal.nim 185 | 186 | var name = "m" 187 | #^^^ storage.modifier.nim keyword.declaration.variable.nim 188 | # ^^^^ entity.name.variable.nim 189 | var noun, pronoun: string 190 | #^^^ storage.modifier.nim keyword.declaration.variable.nim 191 | # ^^^^ entity.name.variable.nim 192 | # ^ punctuation.separator.nim 193 | # ^^^^^^^ entity.name.variable.nim 194 | # ^ punctuation.separator.annotation.nim 195 | # ^^^^^^ storage.type.primitive.nim 196 | var 197 | a = 0 198 | #<- entity.name.variable.nim 199 | # ^ keyword.operator.assignment.nim 200 | b: array[1..10, uint8] 201 | #<- entity.name.variable.nim 202 | #^ punctuation.separator.annotation.nim 203 | # ^^^^^ storage.type.primitive.nim 204 | # ^^^^^^^^^^^^^^ meta.generic.nim 205 | # ^ punctuation.section.generic.begin.nim 206 | # ^ meta.number.integer.decimal.nim constant.numeric.value.nim 207 | # ^^ keyword.operator.nim 208 | # ^^ meta.number.integer.decimal.nim constant.numeric.value.nim 209 | # ^ punctuation.separator.nim 210 | # ^^^^^ storage.type.primitive.nim 211 | # ^ punctuation.section.generic.end.nim 212 | α {.ma}: int 213 | #<- entity.name.variable.nim 214 | # ^^^^^ meta.annotation.nim 215 | # ^ punctuation.separator.annotation.nim 216 | # ^^^ storage.type.primitive.nim 217 | 218 | while true: 219 | #^^^^^ keyword.control.loop.while.nim 220 | # ^^^^ constant.language.nim 221 | # ^ punctuation.section.block.begin.nim 222 | case state: 223 | # ^^^^ keyword.control.conditional.switch.nim 224 | # ^ punctuation.section.block.begin.nim 225 | of asleep: 226 | # ^^ keyword.control.conditional.case.nim 227 | # ^ punctuation.section.block.begin.nim 228 | wakeup() 229 | # ^^^^^^ meta.function-call.nim variable.function.nim 230 | # ^^ meta.function-call.arguments.nim 231 | # ^ punctuation.section.arguments.begin.nim 232 | # ^ punctuation.section.arguments.end.nim 233 | else awake: 234 | # ^^^^ keyword.control.conditional.else.nim 235 | # ^ punctuation.section.block.begin.nim 236 | sleep(`for`=2.days) 237 | # ^^^^^ meta.function-call.nim variable.function.nim 238 | # ^^^^^^^^^^^^^^ meta.function-call.arguments.nim 239 | # ^ punctuation.section.arguments.begin.nim 240 | # ^^^^^ variable.parameter.nim 241 | # ^ keyword.operator.assignment.nim 242 | # ^ meta.number.integer.decimal.nim constant.numeric.value.nim 243 | # ^ punctuation.accessor.dot.nim 244 | # ^ punctuation.section.arguments.end.nim 245 | 246 | for (i, c) in iter: 247 | # ^^^ keyword.control.loop.for.nim 248 | # ^ punctuation.section.parens.begin.nim 249 | # ^ punctuation.separator.nim 250 | # ^ punctuation.section.parens.end.nim 251 | # ^^ keyword.control.loop.for.in.nim 252 | # ^ punctuation.section.block.begin.nim 253 | let a = d[0] 254 | # ^^^ storage.modifier.nim keyword.declaration.variable.nim 255 | # ^ entity.name.variable.nim 256 | # ^ keyword.operator.assignment.nim 257 | # ^ punctuation.section.brackets.begin.nim 258 | # ^ punctuation.section.brackets.end.nim 259 | echo(c) 260 | # ^^^^ meta.function-call.nim variable.function.nim 261 | # ^^^ meta.function-call.arguments.nim 262 | # ^ punctuation.section.arguments.begin.nim 263 | # ^ punctuation.section.arguments.end.nim 264 | proc m: 265 | #^^^^^^^ meta.function.nim 266 | #^^^^ storage.type.function.nim keyword.declaration.function.nim 267 | # ^ entity.name.function.nim 268 | # ^ punctuation.separator.annotation.return.nim 269 | proc proc = 270 | # ^^^^ invalid.illegal.nim 271 | proc addr = 272 | # ^^^^ entity.name.function.nim 273 | proc dα = 274 | # ^^^^^^^^ meta.function.nim 275 | # ^^^^ storage.type.function.nim keyword.declaration.function.nim 276 | # ^^ entity.name.function.nim 277 | # ^ keyword.operator.assignment.nim 278 | 279 | proc 280 | ##[ blah 281 | #^ comment.block.documentation.nim punctuation.definition.comment.begin.nim 282 | ]## 283 | #^^ comment.block.documentation.nim punctuation.definition.comment.end.nim 284 | m = 285 | 286 | proc α(`in` = 1, b, c: int; `in`=1, in = 1) 287 | #^^^^^ meta.function.nim 288 | #^^^ storage.type.function.nim keyword.declaration.function.nim 289 | # ^ entity.name.function.nim 290 | # ^ meta.function.parameters.nim punctuation.section.parameters.begin.nim 291 | # ^^^^ variable.parameter.nim 292 | # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.nim 293 | # ^ keyword.operator.assignment.nim 294 | # ^ meta.number.integer.decimal.nim constant.numeric.value.nim 295 | # ^ punctuation.separator.parameters.nim 296 | # ^ variable.parameter.nim 297 | # ^ punctuation.separator.parameters.nim 298 | # ^ variable.parameter.nim 299 | # ^ punctuation.separator.annotation.parameter.nim 300 | # ^^^ storage.type.primitive.nim 301 | # ^ punctuation.separator.parameters.nim 302 | # ^^^^ variable.parameter.nim 303 | # ^ keyword.operator.assignment.nim 304 | # ^ meta.number.integer.decimal.nim constant.numeric.value.nim 305 | # ^ punctuation.separator.parameters.nim 306 | # ^^ invalid.illegal.nim 307 | # ^ keyword.operator.assignment.nim 308 | # ^ meta.number.integer.decimal.nim constant.numeric.value.nim 309 | # ^ invalid.illegal.nim 310 | 311 | foo(if b: c = d else: d, in = 1) 312 | #^^^ meta.function-call.nim variable.function.nim 313 | # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.nim 314 | # ^ punctuation.section.arguments.begin.nim 315 | # ^^ keyword.control.conditional.if.nim 316 | # ^ punctuation.section.block.begin.nim 317 | # ^ keyword.operator.assignment.nim 318 | # ^^^^ keyword.control.conditional.else.nim 319 | # ^ punctuation.section.block.conditional.else.nim 320 | # ^ punctuation.separator.nim 321 | # ^^ keyword.operator.word.nim 322 | # ^ keyword.operator.assignment.nim 323 | # ^ meta.number.integer.decimal.nim constant.numeric.value.nim 324 | # ^ punctuation.section.arguments.end.nim 325 | 326 | fmt"{123.456=:>9.3f}" 327 | #^^^ meta.function-call.nim variable.function.nim 328 | # ^^^^^^^^^^^^^^^^^^ meta.string.interpolated.nim 329 | # ^ string.quoted.double.nim punctuation.definition.string.begin.nim 330 | # ^^^^^^^^^^^^^^^^ meta.interpolation.nim 331 | # ^ punctuation.section.interpolation.begin.nim 332 | # ^^^^^^^ meta.number.float.decimal.nim constant.numeric.value.nim 333 | # ^^^^^^^ constant.other.format-spec.nim 334 | # ^ punctuation.section.interpolation.end.nim 335 | # ^ string.quoted.double.nim punctuation.definition.string.end.nim 336 | fmt"{x = :}" 337 | #^^^ meta.function-call.nim variable.function.nim 338 | # ^^^^^^^^^ meta.string.interpolated.nim 339 | # ^ string.quoted.double.nim punctuation.definition.string.begin.nim 340 | # ^^^^^^^ meta.interpolation.nim 341 | # ^ punctuation.section.interpolation.begin.nim 342 | # ^^^ constant.other.format-spec.nim 343 | # ^ punctuation.section.interpolation.end.nim 344 | # ^ string.quoted.double.nim punctuation.definition.string.end.nim 345 | fmt"""{ "abc" }""" 346 | #^^^ meta.function-call.nim variable.function.nim 347 | # ^^^^^^^^^^^^^^^ meta.string.interpolated.nim 348 | # ^^^ string.quoted.double.block.nim punctuation.definition.string.begin.nim 349 | # ^^^^^^^^^ meta.interpolation.nim 350 | # ^ punctuation.section.interpolation.begin.nim 351 | # ^^^^^ meta.string.nim string.quoted.double.nim 352 | # ^ punctuation.definition.string.begin.nim 353 | # ^ punctuation.definition.string.end.nim 354 | # ^ punctuation.section.interpolation.end.nim 355 | # ^^^ string.quoted.double.block.nim punctuation.definition.string.end.nim 356 | fmt"""{ "\{(" & x & ")\}" }""" 357 | #^^^ meta.function-call.nim variable.function.nim 358 | # ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.interpolated.nim 359 | # ^^^ string.quoted.double.block.nim punctuation.definition.string.begin.nim 360 | # ^^^^^^^^^^^^^^^^^^^^^ meta.interpolation.nim 361 | # ^ punctuation.section.interpolation.begin.nim 362 | # ^^^^^ meta.string.nim string.quoted.double.nim 363 | # ^ punctuation.definition.string.begin.nim 364 | # ^^ constant.character.escape.nim 365 | # ^ punctuation.definition.string.end.nim 366 | # ^ keyword.operator.nim 367 | # ^^^^^ meta.string.nim string.quoted.double.nim 368 | # ^ punctuation.definition.string.begin.nim 369 | # ^^ constant.character.escape.nim 370 | # ^ punctuation.definition.string.end.nim 371 | # ^ punctuation.section.interpolation.end.nim 372 | # ^^^ string.quoted.double.block.nim punctuation.definition.string.end.nim 373 | fmt"{ \{ {} \}} }" 374 | #^^^ meta.function-call.nim variable.function.nim 375 | # ^^^^^^^^^^^^^^^ meta.string.interpolated.nim 376 | # ^^^^^^^ meta.interpolation.nim 377 | # ^ punctuation.section.interpolation.begin.nim 378 | # ^^ constant.character.escape.nim 379 | # ^ invalid.illegal.nim 380 | # ^ punctuation.section.interpolation.end.nim 381 | # ^^^^^^^ string.quoted.double.nim 382 | # ^^ constant.character.escape.nim 383 | # ^ invalid.illegal.nim 384 | 385 | case e 386 | of A: 387 | #^ keyword.control.conditional.case.nim 388 | # ^ punctuation.section.block.begin.nim 389 | 390 | {.importc: "printf".} 391 | #^^^^^^^^^^^^^^^^^^^^ meta.annotation.nim 392 | #^ punctuation.definition.annotation.begin.nim 393 | # ^^^^^^^ entity.other.attribute-name.pragma.nim 394 | # ^ punctuation.separator.key-value.nim 395 | # ^^^^^^^^ meta.string.nim string.quoted.double.nim 396 | # ^ punctuation.definition.string.begin.nim 397 | # ^ punctuation.definition.string.end.nim 398 | # ^^ punctuation.definition.annotation.end.nim 399 | {.hint[LineTooLong].} 400 | #^^^^^^^^^^^^^^^^^^^^ meta.annotation.nim 401 | #^ punctuation.definition.annotation.begin.nim 402 | # ^^^^ entity.other.attribute-name.pragma.nim 403 | # ^^^^^^^^^^^^^ meta.brackets.nim 404 | # ^ punctuation.section.brackets.begin.nim 405 | # ^^^^^^^^^^^ support.type.nim 406 | # ^ punctuation.section.brackets.end.nim 407 | # ^^ punctuation.definition.annotation.end.nim 408 | {.cast(raises: []).} 409 | #^^^^^^^^^^^^^^^^^^^ meta.annotation.nim 410 | #^ punctuation.definition.annotation.begin.nim 411 | # ^^^^ meta.function-call.nim variable.function.nim 412 | # ^^^^^^^^^^^^ meta.function-call.arguments.nim 413 | # ^ punctuation.section.arguments.begin.nim 414 | # ^^^^^^ variable.parameter.nim 415 | # ^ punctuation.separator.key-value.nim 416 | # ^^ meta.brackets.nim 417 | # ^ punctuation.section.brackets.begin.nim 418 | # ^ punctuation.section.brackets.end.nim 419 | # ^ punctuation.section.arguments.end.nim 420 | # ^^ punctuation.definition.annotation.end.nim 421 | foo int 422 | #^^ meta.function-call.nim variable.function.nim 423 | # ^^^ storage.type.primitive.nim 424 | foo in 425 | # ^^ keyword.operator.word.nim 426 | foo inter 427 | #^^ meta.function-call.nim variable.function.nim 428 | α⊘π 429 | #^ keyword.operator.nim 430 | -------------------------------------------------------------------------------- /Syntaxes/syntax_test.nim.cfg: -------------------------------------------------------------------------------- 1 | # SYNTAX TEST "Packages/NimLime/Syntaxes/Nim CFG.sublime-syntax" 2 | # <- source.nimcfg comment.line.number-sign.nimcfg punctuation.definition.comment.nimcfg 3 | 4 | #[ 5 | ^^ comment.block.nimcfg punctuation.definition.comment.begin 6 | block comment 7 | #^^^^^^^^^^^^^^ comment.block.nimcfg 8 | #[ 9 | nested comment 10 | #^^^^^^^^^^^^^^^^^ comment.block.nimcfg comment.block.nimcfg 11 | ]# 12 | #^^^ comment.block.nimcfg comment.block.nimcfg 13 | # ^^ punctuation.definition.comment.end.nimcfg 14 | ]# 15 | #^ comment.block.nimcfg punctuation.definition.comment.end.nimcfg 16 | 17 | --experimental 18 | #^^ punctuation.definition.variable.nimcfg 19 | --name:"A\nm\L\j\x21" 20 | #^^ punctuation.definition.variable.nimcfg 21 | # ^ punctuation.separator.key-value.nimcfg 22 | # ^^^^^^^^^^^^^^ meta.string.nimcfg string.quoted.double.nimcfg 23 | # ^ punctuation.definition.string.begin.nimcfg 24 | # ^^ constant.character.escape.nimcfg 25 | # ^ invalid.illegal.lone-escape.nimcfg 26 | # ^^^^ constant.character.escape.nimcfg 27 | # ^ punctuation.definition.string.end.nimcfg 28 | multi=""" 29 | # ^^^ meta.string.nimcfg string.quoted.double.block.nimcfg punctuation.definition.string.begin.nimcfg 30 | """ 31 | #^^^^ meta.string.nimcfg string.quoted.double.block.nimcfg 32 | # ^^^ punctuation.definition.string.end.nimcfg 33 | rstr %= R"no \escape \chars\ only """ 34 | # ^^ punctuation.separator.key-value.nimcfg 35 | # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.nimcfg 36 | # ^ storage.type.string.nimcfg 37 | # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double.nimcfg 38 | # ^ punctuation.definition.string.begin.nimcfg 39 | # ^^ constant.character.escape.nimcfg 40 | # ^ punctuation.definition.string.end.nimcfg 41 | 42 | 43 | @if windows or android and not (release or danger): 44 | #<- punctuation.definition.keyword.nimcfg 45 | #^^ keyword.control.conditional.if.nimcfg 46 | # ^^ keyword.operator.logical.nimcfg 47 | # ^^^ keyword.operator.logical.nimcfg 48 | # ^^^ keyword.operator.logical.nimcfg 49 | # ^^^^^^^^^^^^^^^^^^^ meta.group.nimcfg 50 | # ^ punctuation.section.group.begin.nimcfg 51 | # ^^ keyword.operator.logical.nimcfg 52 | # ^ punctuation.section.group.end.nimcfg 53 | # ^ punctuation.section.block.begin.nimcfg 54 | -d:abc 55 | # ^ punctuation.definition.variable.nimcfg 56 | # ^ punctuation.separator.key-value.nimcfg 57 | --define:symbol 58 | # ^^ punctuation.definition.variable.nimcfg 59 | # ^ punctuation.separator.key-value.nimcfg 60 | @elif release: 61 | #^^^^^^^^^^^^^^ meta.block.nimcfg 62 | #<- punctuation.definition.keyword.nimcfg 63 | #^^^^ keyword.control.conditional.elseif.nimcfg 64 | # ^ punctuation.section.block.begin.nimcfg 65 | amd64.windows.gcc.path = "/usr/bin" 66 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.nimcfg 67 | # ^ punctuation.accessor.dot.nimcfg 68 | # ^ punctuation.separator.key-value.nimcfg 69 | # ^^^^^^^^^^ meta.string.nimcfg string.quoted.double.nimcfg 70 | # ^ punctuation.definition.string.begin.nimcfg 71 | # ^ punctuation.definition.string.end.nimcfg 72 | @if osx: 73 | clang.cpp.options.linker = "-Wl,-rpath=.:/usr/local/lib:/usr/pkg/lib:/usr/X11R6/lib" & Foo 74 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.nimcfg meta.block.nimcfg 75 | # ^ punctuation.separator.key-value.nimcfg 76 | # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.nimcfg string.quoted.double.nimcfg 77 | # ^ punctuation.definition.string.begin.nimcfg 78 | # ^ punctuation.definition.string.end.nimcfg 79 | # ^ keyword.operator.nimcfg 80 | --define:key=on 81 | #^^^^^^^^^^^^^^^^ meta.block.nimcfg meta.block.nimcfg 82 | # ^^ punctuation.definition.variable.nimcfg 83 | # ^ punctuation.separator.key-value.nimcfg 84 | # ^^^ string.unquoted.nimcfg 85 | # ^ punctuation.separator.key-value.nimcfg 86 | # ^^ constant.language.boolean.nimcfg 87 | @end 88 | 89 | @else 90 | #<- punctuation.definition.keyword.nimcfg 91 | #^^^^ meta.block.nimcfg 92 | #^^^^ keyword.control.conditional.else.nimcfg 93 | gcc.options.always %= "-w ${gcc.maxerrorsimpl}" 94 | #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.nimcfg 95 | # ^ punctuation.accessor.dot.nimcfg 96 | # ^^ punctuation.separator.key-value.nimcfg 97 | # ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.nimcfg string.quoted.double.nimcfg 98 | # ^ punctuation.definition.string.begin.nimcfg 99 | # ^ punctuation.definition.string.end.nimcfg 100 | @else 101 | 102 | @end 103 | #<- punctuation.definition.keyword.nimcfg 104 | #^^^ keyword.control.conditional.end.nimcfg 105 | 106 | @end 107 | 108 | @if not and windows: 109 | # ^^^ keyword.operator.logical.nimcfg 110 | # ^^^^^ invalid.illegal.nimcfg 111 | # ^ punctuation.separator.key-value.nimcfg 112 | @if or and linux: 113 | # ^^ invalid.illegal.nimcfg 114 | # ^^^ keyword.operator.logical.nimcfg 115 | # ^ punctuation.section.block.begin.nimcfg 116 | @end 117 | 118 | @if not: 119 | # ^ invalid.illegal.nimcfg 120 | @end 121 | 122 | @putenv "KEY" "VALUE" "2 args only!" 123 | #^^^^^^ keyword.other.nimcfg 124 | # ^^^^^ meta.string.nimcfg string.quoted.double.nimcfg 125 | # ^ punctuation.definition.string.begin.nimcfg 126 | # ^ punctuation.definition.string.end.nimcfg 127 | @appendenv X 2 128 | #^^^^^^^^^ keyword.other.nimcfg 129 | # ^ string.unquoted.nimcfg 130 | # ^ meta.number.integer.decimal.nimcfg constant.numeric.value.nimcfg 131 | @prependenv B false 132 | #^^^^^^^^^^ keyword.other.nimcfg 133 | # ^ string.unquoted.nimcfg 134 | # ^^^^^ constant.language.boolean.nimcfg 135 | @write "something" "only one thing" 136 | #<- punctuation.definition.keyword.nimcfg 137 | #^^^^^ keyword.other.nimcfg 138 | # ^^^^^^^^^^^ meta.string.nimcfg string.quoted.double.nimcfg 139 | --------------------------------------------------------------------------------