├── .gitignore ├── .vscode └── launch.json ├── .vscodeignore ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── Makefile ├── README.md ├── examples ├── ayudark_after.png ├── ayudark_before.png ├── dark+_after.png ├── dark+_before.png ├── dracula_after.png └── dracula_before.png ├── icon └── icon.png ├── language-configuration.json ├── package.json ├── syntaxes └── go.tmLanguage.json └── test ├── semantic_tokens.go ├── semantic_tokens.go.snap ├── stress.go └── stress.go.snap /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode/* 2 | !.vscode/launch.json -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Extension", 6 | "type": "extensionHost", 7 | "request": "launch", 8 | "runtimeExecutable": "${execPath}", 9 | "args": [ 10 | "--extensionDevelopmentPath=${workspaceFolder}" 11 | ] 12 | } 13 | ] 14 | } -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | .gitignore 4 | Makefile 5 | examples/** 6 | test/** -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to the "go-syntax" extension will be documented in this file. 4 | 5 | ## [0.8.4] 6 | 7 | - Fixes catastrophic backtracking regex pattern ([#21](https://github.com/worlpaker/go-syntax/pull/21)) 8 | - Fixes minor bugs in variables 9 | 10 | ## [0.8.3] 11 | 12 | - Fixes minor bugs in generic type assertions 13 | 14 | ## [0.8.2] 15 | 16 | - Fixes minor bugs in keyword operators 17 | 18 | ## [0.8.1] 19 | 20 | - Supports the comparable type as `entity.name.type.comparable.go` 21 | - Fixes minor bugs related to generic types in double parentheses and structs 22 | 23 | ## [0.8.0] 24 | 25 | - Supports constant variables 26 | 27 | ## [0.7.9] 28 | 29 | - Fixes minor bugs related to functions ([#17](https://github.com/worlpaker/go-syntax/issues/17)) 30 | 31 | ## [0.7.8] 32 | 33 | - Supports generic alias types 34 | 35 | ## [0.7.7] 36 | 37 | - Fixes minor bugs related to struct fields ([#16](https://github.com/worlpaker/go-syntax/issues/16)) 38 | 39 | ## [0.7.6] 40 | 41 | - Fixes a minor bug in map type 42 | 43 | ## [0.7.5] 44 | 45 | - Fixes a minor bug in switch type 46 | 47 | ## [0.7.4] 48 | 49 | - Fixes a minor bug in interface type 50 | 51 | ## [0.7.3] 52 | 53 | - Fixes property variables (`variable.other.property.field.go` is deprecated) 54 | 55 | ## [0.7.2] 56 | 57 | - Fixes minor bugs in struct field hover and generic type 58 | 59 | ## [0.7.1] 60 | 61 | - Updates `README.md` 62 | 63 | ## [0.7.0] 64 | 65 | - Fixes minor bugs related to multi-line struct tags 66 | 67 | ## [0.6.9] 68 | 69 | - Fixes minor bugs in make built-in function 70 | 71 | ## [0.6.8] 72 | 73 | - Fixes struct field when hovering with the mouse 74 | 75 | ## [0.6.7] 76 | 77 | - Improves constants definitions ([PR 10](https://github.com/worlpaker/go-syntax/pull/10) by [@butuzov](https://github.com/butuzov)) 78 | 79 | ## [0.6.6] 80 | 81 | - Fixes minor bugs in struct and single types 82 | 83 | ## [0.6.5] 84 | 85 | - Fixes a minor bug related to map types in functions 86 | 87 | ## [0.6.4] 88 | 89 | - Fixes a minor bug in struct type 90 | 91 | ## [0.6.3] 92 | 93 | Fixes: 94 | 95 | - Minor bugs in struct type 96 | - Interface type in functions and generics 97 | 98 | ## [0.6.2] 99 | 100 | - Fixes a minor bug in functions inline 101 | 102 | ## [0.6.1] 103 | 104 | Fixes: 105 | 106 | - Minor bugs in interface types and make built-in function 107 | - Early highlighting of variables after control keywords (before formatting with gofmt) 108 | - Early highlighting of types after function declaration (before formatting with gofmt) 109 | 110 | ## [0.6.0] 111 | 112 | - Fixes variables after case keyword in the switch statement 113 | - Fixes variables and types after control keywords 114 | - Removes unnecessary sections 115 | 116 | ## [0.5.9] 117 | 118 | - Fixes a minor bug in double parentheses type 119 | - Improves performance for large files, especially those with long lines of support functions 120 | 121 | ## [0.5.8] 122 | 123 | - Enhances types after the case keyword in the switch type statement 124 | 125 | ## [0.5.7] 126 | 127 | - Refactors map types 128 | - Enhances generics types 129 | - Fixes variable assignment with generic types 130 | - Fixes support functions and functions inline 131 | - Fixes minor bugs in types 132 | 133 | ## [0.5.6] 134 | 135 | Fixes: 136 | 137 | - Minor bugs related to chan keyword in variable assignment 138 | - Property field variables and slice index variables with operators 139 | 140 | ## [0.5.5] 141 | 142 | Fixes: 143 | 144 | - Minor bugs in types related to double parentheses 145 | - Property field variables with comparison operators 146 | - Slice index variables when using arithmetic operators 147 | 148 | ## [0.5.4] 149 | 150 | - Refactors variable assignment and other struct/interface expressions 151 | - Optimizes performance for faster opening of large files, especially those with long lines of variables, parameters, and types 152 | - Implements stress testing to ensure stability and reliability 153 | - Fixes variables 154 | 155 | ## [0.5.3] 156 | 157 | Updates `.vscodeignore` to exclude unnecessary files and folders (`examples`, `test`) 158 | 159 | ## [0.5.2] 160 | 161 | Fixes early highlighting of variables after control keywords (before formatting with gofmt) 162 | 163 | ## [0.5.1] 164 | 165 | Enhances struct property variables (See [#4](https://github.com/worlpaker/go-syntax/issues/4)): 166 | 167 | - struct initialization property variables field will be scoped as `"variable.other.property.field.go"` 168 | 169 | Fixes: 170 | 171 | - minor bugs related to struct types within function declaration 172 | - switch/select case variables with support functions 173 | - early highlighting of struct declaration and variables after control keywords (before formatting with gofmt) 174 | - type declaration with generics on multi-lines 175 | 176 | ## [0.5.0] 177 | 178 | - Enhances function and struct declaration 179 | - Refactors function and generic parameter types 180 | - Supports double parentheses types 181 | - Corrects keyword operator behaviors 182 | - Optimizes code 183 | - Improves documentation 184 | - Removes unnecessary sections 185 | - Adds more tests 186 | - Fixes import declaration with semicolon (before formatting with gofmt) 187 | - Fixes minor bugs in variable declaration, switch case variables, multi type declaration, type assertion, and function in-line 188 | - Fixes bugs related to struct types within function parameters, struct declaration, map types, and variables 189 | 190 | ## [0.4.8] 191 | 192 | - Fixes function declaration 193 | - Fixes generic types in the new built-in function 194 | - Fixes chan in make built-in function, struct type fields, variables, and function parameter types 195 | - Enhances function in-line with support for multi return types 196 | - Improves chan with slices for types 197 | 198 | ## [0.4.7] 199 | 200 | - Fixes early highlighting of variables after control keywords (before formatting with gofmt) 201 | 202 | ## [0.4.6] 203 | 204 | - Fixes minor bugs in new built-in function 205 | 206 | ## [0.4.5] 207 | 208 | - Fixes bugs related to property variables from third party imports 209 | - Fixes minor bugs in map type 210 | 211 | ## [0.4.4] 212 | 213 | - Fixes minor bugs in function declaration 214 | 215 | ## [0.4.3] 216 | 217 | - Fixes minor bugs in struct type 218 | 219 | ## [0.4.2] 220 | 221 | - Fixes multi type declaration 222 | 223 | ## [0.4.1] 224 | 225 | - Fixes minor bugs in generic functions 226 | 227 | ## [0.4.0] 228 | 229 | - Fixes struct type 230 | - Corrects map type with functions 231 | - Updates make and new built-in functions 232 | - Improves function declarations and function inline 233 | - Enhances support for generics in support functions 234 | 235 | ## [0.3.9] 236 | 237 | - Fixes type assertion in switch statements when using support functions 238 | 239 | ## [0.3.8] 240 | 241 | - Fixes minor bugs in type and function declaration 242 | 243 | ## [0.3.7] 244 | 245 | - Fixes pre-highlighting of the single type field in struct before formatting with gofmt 246 | 247 | ## [0.3.6] 248 | 249 | - Enhances generic support for types and functions 250 | 251 | ## [0.3.5] 252 | 253 | - Enhances pre-highlighting of variables after control keywords before formatting with gofmt 254 | 255 | ## [0.3.4] 256 | 257 | - Fixes pre-highlighting of variables after control keywords before formatting with gofmt 258 | 259 | ## [0.3.3] 260 | 261 | - Fixes the preview of variables when hovering with the cursor for the tooltip 262 | 263 | ## [0.3.2] 264 | 265 | - Fixes bugs related to types when declaring variables using the var keyword 266 | 267 | ## [0.3.1] 268 | 269 | - Enhances generic type support for map types 270 | 271 | ## [0.3.0] 272 | 273 | - Updates `README.md` 274 | 275 | ## [0.2.40] 276 | 277 | - Improves generic type support with map when declaring variables using the var keyword 278 | - Adds new snap commands for test 279 | 280 | ## [0.2.39] 281 | 282 | - Enhances generic type support with map for the built-in make function 283 | 284 | ## [0.2.38] 285 | 286 | - Improves generic type support for the built-in make function 287 | 288 | ## [0.2.37] 289 | 290 | - Fixes a bug related to function types with var keyword 291 | 292 | ## [0.2.36] 293 | 294 | - Fixes bug related to returning multiple params in functions in-line 295 | 296 | ## [0.2.35] 297 | 298 | - Fixes a small bug related to generics in functions in-line 299 | 300 | ## [0.2.34] 301 | 302 | - Fixes minor bugs in function declarations 303 | - Enhances code readability 304 | - Removes unnecessary sections 305 | 306 | ## [0.2.33] 307 | 308 | - Fixes a small bug in function declaration 309 | 310 | ## [0.2.32] 311 | 312 | - Fixes a small bug in make built-in function 313 | 314 | ## [0.2.31] 315 | 316 | - Fixes small bugs related to types within function declaration 317 | 318 | ## [0.2.30] 319 | 320 | - Fixes a small bug in new built-in function 321 | 322 | ## [0.2.29] 323 | 324 | - Fixes minor bugs related to variable types within functions 325 | - Enhances generic support in functions 326 | - Improves type support for the built-in make function 327 | - Introduces new built-in functions: min, max, and clear 328 | 329 | ## [0.2.28] 330 | 331 | - Fixes small bugs in variables 332 | 333 | ## [0.2.27] 334 | 335 | - Fixes small bugs in interface types 336 | 337 | ## [0.2.26] 338 | 339 | - Fixes a small bug in interface types 340 | 341 | ## [0.2.25] 342 | 343 | - Fixes small bugs in switch type assertion 344 | 345 | ## [0.2.24] 346 | 347 | - Fixes small bugs in variable types 348 | 349 | ## [0.2.23] 350 | 351 | - Fixes a small bug in variable types 352 | 353 | ## [0.2.22] 354 | 355 | - Fixes small bugs in all types 356 | 357 | ## [0.2.21] 358 | 359 | - Fixes small bugs in generic types 360 | 361 | ## [0.2.20] 362 | 363 | Starting from now, the extension will provide significantly enhanced support for variables compared to previous versions. 364 | 365 | Details: 366 | 367 | - Variable parameters in functions and generics will be scoped as "variable.parameter.go" 368 | - Variable names in structs and struct initialization will be scoped as "variable.other.property.go" 369 | - Variable names in imports will be scoped as "variable.other.import.go" 370 | - Loop label names will be scoped as "variable.other.label.go" 371 | 372 | ## [0.2.19] 373 | 374 | Add support for: 375 | 376 | - Variable parameters in functions 377 | - Variable parameters in generics 378 | - Variable names in struct 379 | - Variable names in struct initialization 380 | - Label loop names 381 | 382 | ## [0.2.18] 383 | 384 | - Enhances generic support in all types 385 | 386 | ## [0.2.17] 387 | 388 | - Enhances generic support in function declarations 389 | 390 | ## [0.2.16] 391 | 392 | - Adds a new icon 393 | 394 | ## [0.2.15] 395 | 396 | - Fixes a small bug related to structs in function parameters 397 | 398 | ## [0.2.14] 399 | 400 | - Adds type support to the new keyword (to instantiate a struct) 401 | 402 | ## [0.2.13] 403 | 404 | - Fixes a small bug in import 405 | 406 | ## [0.2.12] 407 | 408 | - Adds generic support to support functions 409 | - Fixes small bugs (interface types, type assertions) 410 | 411 | ## [0.2.11] 412 | 413 | - Fixes small bug in map types 414 | 415 | ## [0.2.10] 416 | 417 | - Fixes small bugs in struct fields 418 | 419 | ## [0.2.9] 420 | 421 | - Fixes incorrect highlighting for multidimensional slice type in struct's fields 422 | 423 | ## [0.2.8] 424 | 425 | - Fixes small bugs in function declaration 426 | 427 | ## [0.2.7] 428 | 429 | - Fixes different colors (storage types) in support functions with a new solution 430 | 431 | ## [0.2.6] 432 | 433 | - Fixes decrementing operator highlighting in for loop 434 | - Fixes a small bug that occurred in the v0.2.5 435 | 436 | ## [0.2.5] 437 | 438 | - Fixes different colors (storage types) in support functions 439 | 440 | ## [0.2.4] 441 | 442 | - Adds generic support to the struct 443 | 444 | ## [0.2.3] 445 | 446 | - Stable Version 447 | 448 | ## [0.2.2] 449 | 450 | - Fixes unnecessary highlighting (control keywords) 451 | 452 | ## [0.2.1] 453 | 454 | - Fixes unnecessary highlighting (other struct expressions, other type names) 455 | 456 | ## [0.2.0] 457 | 458 | - Stable Version 459 | 460 | ## [0.1.1] 461 | 462 | - Fixes other type names declaration in function 463 | 464 | ## [0.1.0] 465 | 466 | - First version of Go Syntax 467 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guide 2 | 3 | Thanks for your interest in contributing to Go Syntax! 4 | 5 | Any kind of PR (e.g., tests, performance improvements, bug fixes, features, typos) is welcome! 6 | 7 | We include a simple scenario demonstrating each change in [semantic_tokens.go](test/semantic_tokens.go). We take advantage of Git version control to test changes. Eventually, running tests will generate snapshot files, and we will be able to see the differences. This helps us to ensure that we are not breaking anything in the existing sample code. 8 | 9 | ## Test 10 | 11 | Please add a sample of Go code related to your PR in [semantic_tokens.go](test/semantic_tokens.go). Refer to the [Makefile](Makefile) for detailed test commands. 12 | 13 | You need to install [vscode-tmgrammar-test](https://www.npmjs.com/package/vscode-tmgrammar-test) before running the tests. 14 | 15 | Install it globally: 16 | 17 | ```sh 18 | npm i -g vscode-tmgrammar-test 19 | ``` 20 | 21 | In the go-syntax directory, run the following tests: 22 | 23 | 1. Stress Test 24 | 25 | ```sh 26 | make stress 27 | ``` 28 | 29 | 2. Semantic Tokens Test 30 | 31 | ```sh 32 | make ready 33 | ``` 34 | 35 | > Many changes may occur in the tests depending on your PR, which is fine. 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Furkan Ozalp 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, 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, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Ensure 'vscode-tmgrammar-test' is installed before running these tests. 2 | 3 | tests: 4 | vscode-tmgrammar-test ./test/semantic_tokens.go 5 | snap: 6 | vscode-tmgrammar-snap ./test/semantic_tokens.go -u 7 | new-snap: 8 | vscode-tmgrammar-snap ./test/semantic_tokens.go 9 | stress: 10 | vscode-tmgrammar-test ./test/stress.go 11 | vscode-tmgrammar-snap ./test/stress.go -u 12 | ready: tests snap 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Go Syntax 2 | 3 | Rich Syntax Highlighting for [Go](https://go.dev/) language 4 | 5 | With this extension, your favorite theme will be able to color your code better. 6 | 7 | > **NOTE:** Go Syntax became the default [Go grammar](https://github.com/microsoft/vscode/blob/main/extensions/go/syntaxes/go.tmLanguage.json) in the official VS Code in v1.86 ([release note](https://code.visualstudio.com/updates/v1_86#_new-go-grammar)). 8 | 9 | ## About 10 | 11 | Go Syntax improves your coding experience by providing client-side syntax highlighting based on [TextMate rules](https://macromates.com/manual/en/language_grammars). This means you can enjoy advanced code coloring without relying on the Language Server Protocol (LSP). 12 | 13 | It is compatible with various platforms, including web-based code editors like [vscode.dev](https://vscode.dev) and [github.dev](https://github.dev). 14 | 15 | ![dark+_theme](examples/dark+_after.png) 16 | 17 | **⚠️ Warning:** [Gopls' `ui.semanticTokens` setting](https://github.com/golang/vscode-go/wiki/settings#uisemantictokens) is disabled by default, and enabling semantic highlighting might override the tokens. 18 | 19 | ## Contributing 20 | 21 | Yes, please! Feel free to contribute. Check out [CONTRIBUTING.md](CONTRIBUTING.md). 22 | 23 | ## Credits 24 | 25 | This extension enhances [better-go-syntax](https://github.com/jeff-hykin/better-go-syntax) with new features. 26 | 27 | Semantic tokens tested thanks to the [vscode-tmgrammar-test](https://github.com/PanAeon/vscode-tmgrammar-test). 28 | 29 | ## License 30 | 31 | [MIT](https://github.com/worlpaker/go-syntax/blob/master/LICENSE) 32 | -------------------------------------------------------------------------------- /examples/ayudark_after.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/worlpaker/go-syntax/032ca47e859444370914c8726486a47735fc7d0c/examples/ayudark_after.png -------------------------------------------------------------------------------- /examples/ayudark_before.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/worlpaker/go-syntax/032ca47e859444370914c8726486a47735fc7d0c/examples/ayudark_before.png -------------------------------------------------------------------------------- /examples/dark+_after.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/worlpaker/go-syntax/032ca47e859444370914c8726486a47735fc7d0c/examples/dark+_after.png -------------------------------------------------------------------------------- /examples/dark+_before.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/worlpaker/go-syntax/032ca47e859444370914c8726486a47735fc7d0c/examples/dark+_before.png -------------------------------------------------------------------------------- /examples/dracula_after.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/worlpaker/go-syntax/032ca47e859444370914c8726486a47735fc7d0c/examples/dracula_after.png -------------------------------------------------------------------------------- /examples/dracula_before.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/worlpaker/go-syntax/032ca47e859444370914c8726486a47735fc7d0c/examples/dracula_before.png -------------------------------------------------------------------------------- /icon/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/worlpaker/go-syntax/032ca47e859444370914c8726486a47735fc7d0c/icon/icon.png -------------------------------------------------------------------------------- /language-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "comments": { 3 | // symbol used for single line comment. Remove this entry if your language does not support line comments 4 | "lineComment": "//", 5 | // symbols used for start and end a block comment. Remove this entry if your language does not support block comments 6 | "blockComment": [ "/*", "*/" ] 7 | }, 8 | // symbols used as brackets 9 | "brackets": [ 10 | ["{", "}"], 11 | ["[", "]"], 12 | ["(", ")"] 13 | ], 14 | // symbols that are auto closed when typing 15 | "autoClosingPairs": [ 16 | ["{", "}"], 17 | ["[", "]"], 18 | ["(", ")"], 19 | ["\"", "\""], 20 | ["'", "'"] 21 | ], 22 | // symbols that can be used to surround a selection 23 | "surroundingPairs": [ 24 | ["{", "}"], 25 | ["[", "]"], 26 | ["(", ")"], 27 | ["\"", "\""], 28 | ["'", "'"] 29 | ] 30 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "go-syntax", 3 | "displayName": "Go Syntax", 4 | "description": "Rich Syntax Highlighting for Go language", 5 | "version": "0.8.4", 6 | "author": "Furkan Ozalp", 7 | "publisher": "furkanozalp", 8 | "license": "MIT", 9 | "icon": "icon/icon.png", 10 | "repository": { 11 | "types": "git", 12 | "url": "https://github.com/worlpaker/go-syntax.git" 13 | }, 14 | "bugs": { 15 | "url": "https://github.com/worlpaker/go-syntax/issues" 16 | }, 17 | "engines": { 18 | "vscode": "^1.0.0" 19 | }, 20 | "categories": [ 21 | "Programming Languages" 22 | ], 23 | "keywords": [ 24 | "go", 25 | "golang", 26 | "syntax", 27 | "textmate", 28 | "highlighting", 29 | "coloring", 30 | "color" 31 | ], 32 | "contributes": { 33 | "languages": [ 34 | { 35 | "id": "go", 36 | "aliases": [ 37 | "Go", 38 | "go" 39 | ], 40 | "extensions": [ 41 | ".go" 42 | ], 43 | "configuration": "./language-configuration.json" 44 | } 45 | ], 46 | "grammars": [ 47 | { 48 | "language": "go", 49 | "scopeName": "source.go", 50 | "path": "./syntaxes/go.tmLanguage.json" 51 | } 52 | ] 53 | } 54 | } -------------------------------------------------------------------------------- /syntaxes/go.tmLanguage.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Go", 3 | "scopeName": "source.go", 4 | "patterns": [ 5 | { 6 | "include": "#statements" 7 | } 8 | ], 9 | "repository": { 10 | "statements": { 11 | "patterns": [ 12 | { 13 | "include": "#package_name" 14 | }, 15 | { 16 | "include": "#import" 17 | }, 18 | { 19 | "include": "#syntax_errors" 20 | }, 21 | { 22 | "include": "#group-functions" 23 | }, 24 | { 25 | "include": "#group-types" 26 | }, 27 | { 28 | "include": "#group-variables" 29 | }, 30 | { 31 | "include": "#field_hover" 32 | } 33 | ] 34 | }, 35 | "group-functions": { 36 | "comment": "all statements related to functions", 37 | "patterns": [ 38 | { 39 | "include": "#function_declaration" 40 | }, 41 | { 42 | "include": "#functions_inline" 43 | }, 44 | { 45 | "include": "#functions" 46 | }, 47 | { 48 | "include": "#built_in_functions" 49 | }, 50 | { 51 | "include": "#support_functions" 52 | } 53 | ] 54 | }, 55 | "group-types": { 56 | "comment": "all statements related to types", 57 | "patterns": [ 58 | { 59 | "include": "#other_struct_interface_expressions" 60 | }, 61 | { 62 | "include": "#type_assertion_inline" 63 | }, 64 | { 65 | "include": "#struct_variables_types" 66 | }, 67 | { 68 | "include": "#interface_variables_types" 69 | }, 70 | { 71 | "include": "#single_type" 72 | }, 73 | { 74 | "include": "#multi_types" 75 | }, 76 | { 77 | "include": "#struct_interface_declaration" 78 | }, 79 | { 80 | "include": "#double_parentheses_types" 81 | }, 82 | { 83 | "include": "#switch_types" 84 | }, 85 | { 86 | "include": "#type-declarations" 87 | } 88 | ] 89 | }, 90 | "group-variables": { 91 | "comment": "all statements related to variables", 92 | "patterns": [ 93 | { 94 | "include": "#const_assignment" 95 | }, 96 | { 97 | "include": "#var_assignment" 98 | }, 99 | { 100 | "include": "#variable_assignment" 101 | }, 102 | { 103 | "include": "#label_loop_variables" 104 | }, 105 | { 106 | "include": "#slice_index_variables" 107 | }, 108 | { 109 | "include": "#property_variables" 110 | }, 111 | { 112 | "include": "#switch_variables" 113 | }, 114 | { 115 | "include": "#other_variables" 116 | } 117 | ] 118 | }, 119 | "type-declarations": { 120 | "comment": "includes all type declarations", 121 | "patterns": [ 122 | { 123 | "include": "#language_constants" 124 | }, 125 | { 126 | "include": "#comments" 127 | }, 128 | { 129 | "include": "#map_types" 130 | }, 131 | { 132 | "include": "#brackets" 133 | }, 134 | { 135 | "include": "#delimiters" 136 | }, 137 | { 138 | "include": "#keywords" 139 | }, 140 | { 141 | "include": "#operators" 142 | }, 143 | { 144 | "include": "#runes" 145 | }, 146 | { 147 | "include": "#storage_types" 148 | }, 149 | { 150 | "include": "#raw_string_literals" 151 | }, 152 | { 153 | "include": "#string_literals" 154 | }, 155 | { 156 | "include": "#numeric_literals" 157 | }, 158 | { 159 | "include": "#terminators" 160 | } 161 | ] 162 | }, 163 | "type-declarations-without-brackets": { 164 | "comment": "includes all type declarations without brackets (in some cases, brackets need to be captured manually)", 165 | "patterns": [ 166 | { 167 | "include": "#language_constants" 168 | }, 169 | { 170 | "include": "#comments" 171 | }, 172 | { 173 | "include": "#map_types" 174 | }, 175 | { 176 | "include": "#delimiters" 177 | }, 178 | { 179 | "include": "#keywords" 180 | }, 181 | { 182 | "include": "#operators" 183 | }, 184 | { 185 | "include": "#runes" 186 | }, 187 | { 188 | "include": "#storage_types" 189 | }, 190 | { 191 | "include": "#raw_string_literals" 192 | }, 193 | { 194 | "include": "#string_literals" 195 | }, 196 | { 197 | "include": "#numeric_literals" 198 | }, 199 | { 200 | "include": "#terminators" 201 | } 202 | ] 203 | }, 204 | "parameter-variable-types": { 205 | "comment": "function and generic parameter types", 206 | "patterns": [ 207 | { 208 | "match": "\\{", 209 | "name": "punctuation.definition.begin.bracket.curly.go" 210 | }, 211 | { 212 | "match": "\\}", 213 | "name": "punctuation.definition.end.bracket.curly.go" 214 | }, 215 | { 216 | "begin": "([\\w\\.\\*]+)?(\\[)", 217 | "beginCaptures": { 218 | "1": { 219 | "patterns": [ 220 | { 221 | "include": "#type-declarations" 222 | }, 223 | { 224 | "match": "\\w+", 225 | "name": "entity.name.type.go" 226 | } 227 | ] 228 | }, 229 | "2": { 230 | "name": "punctuation.definition.begin.bracket.square.go" 231 | } 232 | }, 233 | "end": "\\]", 234 | "endCaptures": { 235 | "0": { 236 | "name": "punctuation.definition.end.bracket.square.go" 237 | } 238 | }, 239 | "patterns": [ 240 | { 241 | "include": "#generic_param_types" 242 | } 243 | ] 244 | }, 245 | { 246 | "begin": "\\(", 247 | "beginCaptures": { 248 | "0": { 249 | "name": "punctuation.definition.begin.bracket.round.go" 250 | } 251 | }, 252 | "end": "\\)", 253 | "endCaptures": { 254 | "0": { 255 | "name": "punctuation.definition.end.bracket.round.go" 256 | } 257 | }, 258 | "patterns": [ 259 | { 260 | "include": "#function_param_types" 261 | } 262 | ] 263 | } 264 | ] 265 | }, 266 | "language_constants": { 267 | "comment": "Language constants", 268 | "match": "\\b(?:(true|false)|(nil)|(iota))\\b", 269 | "captures": { 270 | "1": { 271 | "name": "constant.language.boolean.go" 272 | }, 273 | "2": { 274 | "name": "constant.language.null.go" 275 | }, 276 | "3": { 277 | "name": "constant.language.iota.go" 278 | } 279 | } 280 | }, 281 | "comments": { 282 | "patterns": [ 283 | { 284 | "name": "comment.block.go", 285 | "begin": "(\\/\\*)", 286 | "beginCaptures": { 287 | "1": { 288 | "name": "punctuation.definition.comment.go" 289 | } 290 | }, 291 | "end": "(\\*\\/)", 292 | "endCaptures": { 293 | "1": { 294 | "name": "punctuation.definition.comment.go" 295 | } 296 | } 297 | }, 298 | { 299 | "name": "comment.line.double-slash.go", 300 | "begin": "(\\/\\/)", 301 | "beginCaptures": { 302 | "1": { 303 | "name": "punctuation.definition.comment.go" 304 | } 305 | }, 306 | "end": "(?:\\n|$)" 307 | } 308 | ] 309 | }, 310 | "map_types": { 311 | "comment": "map types", 312 | "begin": "(\\bmap\\b)(\\[)", 313 | "beginCaptures": { 314 | "1": { 315 | "name": "keyword.map.go" 316 | }, 317 | "2": { 318 | "name": "punctuation.definition.begin.bracket.square.go" 319 | } 320 | }, 321 | "end": "(?:(\\])((?:(?:(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?(?!(?:[\\[\\]\\*]+)?\\b(?:func|struct|map)\\b)(?:[\\*\\[\\]]+)?(?:[\\w\\.]+)(?:\\[(?:(?:[\\w\\.\\*\\[\\]\\{\\}]+)(?:(?:\\,\\s*(?:[\\w\\.\\*\\[\\]\\{\\}]+))*))?\\])?)?)", 322 | "endCaptures": { 323 | "1": { 324 | "name": "punctuation.definition.end.bracket.square.go" 325 | }, 326 | "2": { 327 | "patterns": [ 328 | { 329 | "include": "#type-declarations-without-brackets" 330 | }, 331 | { 332 | "match": "\\[", 333 | "name": "punctuation.definition.begin.bracket.square.go" 334 | }, 335 | { 336 | "match": "\\]", 337 | "name": "punctuation.definition.end.bracket.square.go" 338 | }, 339 | { 340 | "match": "\\w+", 341 | "name": "entity.name.type.go" 342 | } 343 | ] 344 | } 345 | }, 346 | "patterns": [ 347 | { 348 | "include": "#type-declarations-without-brackets" 349 | }, 350 | { 351 | "include": "#parameter-variable-types" 352 | }, 353 | { 354 | "include": "#functions" 355 | }, 356 | { 357 | "match": "\\[", 358 | "name": "punctuation.definition.begin.bracket.square.go" 359 | }, 360 | { 361 | "match": "\\]", 362 | "name": "punctuation.definition.end.bracket.square.go" 363 | }, 364 | { 365 | "match": "\\{", 366 | "name": "punctuation.definition.begin.bracket.curly.go" 367 | }, 368 | { 369 | "match": "\\}", 370 | "name": "punctuation.definition.end.bracket.curly.go" 371 | }, 372 | { 373 | "match": "\\(", 374 | "name": "punctuation.definition.begin.bracket.round.go" 375 | }, 376 | { 377 | "match": "\\)", 378 | "name": "punctuation.definition.end.bracket.round.go" 379 | }, 380 | { 381 | "match": "\\w+", 382 | "name": "entity.name.type.go" 383 | } 384 | ] 385 | }, 386 | "brackets": { 387 | "patterns": [ 388 | { 389 | "begin": "\\{", 390 | "beginCaptures": { 391 | "0": { 392 | "name": "punctuation.definition.begin.bracket.curly.go" 393 | } 394 | }, 395 | "end": "\\}", 396 | "endCaptures": { 397 | "0": { 398 | "name": "punctuation.definition.end.bracket.curly.go" 399 | } 400 | }, 401 | "patterns": [ 402 | { 403 | "include": "$self" 404 | } 405 | ] 406 | }, 407 | { 408 | "begin": "\\(", 409 | "beginCaptures": { 410 | "0": { 411 | "name": "punctuation.definition.begin.bracket.round.go" 412 | } 413 | }, 414 | "end": "\\)", 415 | "endCaptures": { 416 | "0": { 417 | "name": "punctuation.definition.end.bracket.round.go" 418 | } 419 | }, 420 | "patterns": [ 421 | { 422 | "include": "$self" 423 | } 424 | ] 425 | }, 426 | { 427 | "begin": "\\[", 428 | "beginCaptures": { 429 | "0": { 430 | "name": "punctuation.definition.begin.bracket.square.go" 431 | } 432 | }, 433 | "end": "\\]", 434 | "endCaptures": { 435 | "0": { 436 | "name": "punctuation.definition.end.bracket.square.go" 437 | } 438 | }, 439 | "patterns": [ 440 | { 441 | "include": "$self" 442 | } 443 | ] 444 | } 445 | ] 446 | }, 447 | "delimiters": { 448 | "patterns": [ 449 | { 450 | "match": "\\,", 451 | "name": "punctuation.other.comma.go" 452 | }, 453 | { 454 | "match": "\\.(?!\\.\\.)", 455 | "name": "punctuation.other.period.go" 456 | }, 457 | { 458 | "match": ":(?!=)", 459 | "name": "punctuation.other.colon.go" 460 | } 461 | ] 462 | }, 463 | "keywords": { 464 | "patterns": [ 465 | { 466 | "comment": "Flow control keywords", 467 | "match": "\\b(break|case|continue|default|defer|else|fallthrough|for|go|goto|if|range|return|select|switch)\\b", 468 | "name": "keyword.control.go" 469 | }, 470 | { 471 | "match": "\\bchan\\b", 472 | "name": "keyword.channel.go" 473 | }, 474 | { 475 | "match": "\\bconst\\b", 476 | "name": "keyword.const.go" 477 | }, 478 | { 479 | "match": "\\bvar\\b", 480 | "name": "keyword.var.go" 481 | }, 482 | { 483 | "match": "\\bfunc\\b", 484 | "name": "keyword.function.go" 485 | }, 486 | { 487 | "match": "\\binterface\\b", 488 | "name": "keyword.interface.go" 489 | }, 490 | { 491 | "match": "\\bmap\\b", 492 | "name": "keyword.map.go" 493 | }, 494 | { 495 | "match": "\\bstruct\\b", 496 | "name": "keyword.struct.go" 497 | }, 498 | { 499 | "match": "\\bimport\\b", 500 | "name": "keyword.control.import.go" 501 | }, 502 | { 503 | "match": "\\btype\\b", 504 | "name": "keyword.type.go" 505 | } 506 | ] 507 | }, 508 | "operators": { 509 | "comment": "Note that the order here is very important!", 510 | "patterns": [ 511 | { 512 | "match": "(?=|<(?!<)|>(?!>))", 529 | "name": "keyword.operator.comparison.go" 530 | }, 531 | { 532 | "match": "(&&|\\|\\||!)", 533 | "name": "keyword.operator.logical.go" 534 | }, 535 | { 536 | "match": "(=|\\+=|\\-=|\\|=|\\^=|\\*=|/=|:=|%=|<<=|>>=|&\\^=|&=)", 537 | "name": "keyword.operator.assignment.go" 538 | }, 539 | { 540 | "match": "(\\+|\\-|\\*|/|%)", 541 | "name": "keyword.operator.arithmetic.go" 542 | }, 543 | { 544 | "match": "(&(?!\\^)|\\||\\^|&\\^|<<|>>|\\~)", 545 | "name": "keyword.operator.arithmetic.bitwise.go" 546 | }, 547 | { 548 | "match": "\\.\\.\\.", 549 | "name": "keyword.operator.ellipsis.go" 550 | } 551 | ] 552 | }, 553 | "runes": { 554 | "patterns": [ 555 | { 556 | "begin": "'", 557 | "beginCaptures": { 558 | "0": { 559 | "name": "punctuation.definition.string.begin.go" 560 | } 561 | }, 562 | "end": "'", 563 | "endCaptures": { 564 | "0": { 565 | "name": "punctuation.definition.string.end.go" 566 | } 567 | }, 568 | "name": "string.quoted.rune.go", 569 | "patterns": [ 570 | { 571 | "match": "\\G(\\\\([0-7]{3}|[abfnrtv\\\\'\"]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})|.)(?=')", 572 | "name": "constant.other.rune.go" 573 | }, 574 | { 575 | "match": "[^']+", 576 | "name": "invalid.illegal.unknown-rune.go" 577 | } 578 | ] 579 | } 580 | ] 581 | }, 582 | "storage_types": { 583 | "patterns": [ 584 | { 585 | "match": "\\bbool\\b", 586 | "name": "storage.type.boolean.go" 587 | }, 588 | { 589 | "match": "\\bbyte\\b", 590 | "name": "storage.type.byte.go" 591 | }, 592 | { 593 | "match": "\\berror\\b", 594 | "name": "storage.type.error.go" 595 | }, 596 | { 597 | "match": "\\b(complex(64|128)|float(32|64)|u?int(8|16|32|64)?)\\b", 598 | "name": "storage.type.numeric.go" 599 | }, 600 | { 601 | "match": "\\brune\\b", 602 | "name": "storage.type.rune.go" 603 | }, 604 | { 605 | "match": "\\bstring\\b", 606 | "name": "storage.type.string.go" 607 | }, 608 | { 609 | "match": "\\buintptr\\b", 610 | "name": "storage.type.uintptr.go" 611 | }, 612 | { 613 | "match": "\\bany\\b", 614 | "name": "entity.name.type.any.go" 615 | }, 616 | { 617 | "match": "\\bcomparable\\b", 618 | "name": "entity.name.type.comparable.go" 619 | } 620 | ] 621 | }, 622 | "raw_string_literals": { 623 | "comment": "Raw string literals", 624 | "begin": "`", 625 | "beginCaptures": { 626 | "0": { 627 | "name": "punctuation.definition.string.begin.go" 628 | } 629 | }, 630 | "end": "`", 631 | "endCaptures": { 632 | "0": { 633 | "name": "punctuation.definition.string.end.go" 634 | } 635 | }, 636 | "name": "string.quoted.raw.go", 637 | "patterns": [ 638 | { 639 | "include": "#string_placeholder" 640 | } 641 | ] 642 | }, 643 | "string_literals": { 644 | "patterns": [ 645 | { 646 | "comment": "Interpreted string literals", 647 | "begin": "\"", 648 | "beginCaptures": { 649 | "0": { 650 | "name": "punctuation.definition.string.begin.go" 651 | } 652 | }, 653 | "end": "\"", 654 | "endCaptures": { 655 | "0": { 656 | "name": "punctuation.definition.string.end.go" 657 | } 658 | }, 659 | "name": "string.quoted.double.go", 660 | "patterns": [ 661 | { 662 | "include": "#string_escaped_char" 663 | }, 664 | { 665 | "include": "#string_placeholder" 666 | } 667 | ] 668 | } 669 | ] 670 | }, 671 | "string_escaped_char": { 672 | "patterns": [ 673 | { 674 | "match": "\\\\([0-7]{3}|[abfnrtv\\\\'\"]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})", 675 | "name": "constant.character.escape.go" 676 | }, 677 | { 678 | "match": "\\\\[^0-7xuUabfnrtv\\'\"]", 679 | "name": "invalid.illegal.unknown-escape.go" 680 | } 681 | ] 682 | }, 683 | "string_placeholder": { 684 | "patterns": [ 685 | { 686 | "match": "%(\\[\\d+\\])?([\\+#\\-0\\x20]{,2}((\\d+|\\*)?(\\.?(\\d+|\\*|(\\[\\d+\\])\\*?)?(\\[\\d+\\])?)?))?[vT%tbcdoqxXUbeEfFgGspw]", 687 | "name": "constant.other.placeholder.go" 688 | } 689 | ] 690 | }, 691 | "numeric_literals": { 692 | "match": "(?\\-]+(?:\\s*)(?:\\/(?:\\/|\\*).*)?)$)", 1274 | "captures": { 1275 | "1": { 1276 | "patterns": [ 1277 | { 1278 | "include": "#type-declarations-without-brackets" 1279 | }, 1280 | { 1281 | "include": "#parameter-variable-types" 1282 | }, 1283 | { 1284 | "match": "\\w+", 1285 | "name": "entity.name.type.go" 1286 | } 1287 | ] 1288 | } 1289 | } 1290 | }, 1291 | { 1292 | "include": "$self" 1293 | } 1294 | ] 1295 | }, 1296 | "function_param_types": { 1297 | "comment": "function parameter variables and types", 1298 | "patterns": [ 1299 | { 1300 | "include": "#struct_variables_types" 1301 | }, 1302 | { 1303 | "include": "#interface_variables_types" 1304 | }, 1305 | { 1306 | "include": "#type-declarations-without-brackets" 1307 | }, 1308 | { 1309 | "comment": "struct/interface type declaration", 1310 | "match": "((?:(?:\\b\\w+\\,\\s*)+)?\\b\\w+)\\s+(?=(?:(?:\\s*(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?(?:[\\[\\]\\*]+)?\\b(?:struct|interface)\\b\\s*\\{)", 1311 | "captures": { 1312 | "1": { 1313 | "patterns": [ 1314 | { 1315 | "include": "#type-declarations" 1316 | }, 1317 | { 1318 | "match": "\\w+", 1319 | "name": "variable.parameter.go" 1320 | } 1321 | ] 1322 | } 1323 | } 1324 | }, 1325 | { 1326 | "comment": "multiple parameters one type -with multilines", 1327 | "match": "(?:(?:(?<=\\()|^\\s*)((?:(?:\\b\\w+\\,\\s*)+)(?:\/(?:\/|\\*).*)?)$)", 1328 | "captures": { 1329 | "1": { 1330 | "patterns": [ 1331 | { 1332 | "include": "#type-declarations" 1333 | }, 1334 | { 1335 | "match": "\\w+", 1336 | "name": "variable.parameter.go" 1337 | } 1338 | ] 1339 | } 1340 | } 1341 | }, 1342 | { 1343 | "comment": "multiple params and types | multiple params one type | one param one type", 1344 | "match": "(?:((?:(?:\\b\\w+\\,\\s*)+)?\\b\\w+)(?:\\s+)((?:(?:\\s*(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?(?:(?:(?:[\\w\\[\\]\\.\\*]+)?(?:(?:\\bfunc\\b\\((?:[^\\)]+)?\\))(?:(?:\\s*(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?(?:\\s*))+(?:(?:(?:[\\w\\*\\.\\[\\]]+)|(?:\\((?:[^\\)]+)?\\))))?)|(?:(?:[\\[\\]\\*]+)?[\\w\\*\\.]+(?:\\[(?:[^\\]]+)\\])?(?:[\\w\\.\\*]+)?)+)))", 1345 | "captures": { 1346 | "1": { 1347 | "patterns": [ 1348 | { 1349 | "include": "#delimiters" 1350 | }, 1351 | { 1352 | "match": "\\w+", 1353 | "name": "variable.parameter.go" 1354 | } 1355 | ] 1356 | }, 1357 | "2": { 1358 | "patterns": [ 1359 | { 1360 | "include": "#type-declarations-without-brackets" 1361 | }, 1362 | { 1363 | "include": "#parameter-variable-types" 1364 | }, 1365 | { 1366 | "match": "\\w+", 1367 | "name": "entity.name.type.go" 1368 | } 1369 | ] 1370 | } 1371 | } 1372 | }, 1373 | { 1374 | "begin": "([\\w\\.\\*]+)?(\\[)", 1375 | "beginCaptures": { 1376 | "1": { 1377 | "patterns": [ 1378 | { 1379 | "include": "#type-declarations" 1380 | }, 1381 | { 1382 | "match": "\\w+", 1383 | "name": "entity.name.type.go" 1384 | } 1385 | ] 1386 | }, 1387 | "2": { 1388 | "name": "punctuation.definition.begin.bracket.square.go" 1389 | } 1390 | }, 1391 | "end": "\\]", 1392 | "endCaptures": { 1393 | "0": { 1394 | "name": "punctuation.definition.end.bracket.square.go" 1395 | } 1396 | }, 1397 | "patterns": [ 1398 | { 1399 | "include": "#generic_param_types" 1400 | } 1401 | ] 1402 | }, 1403 | { 1404 | "begin": "\\(", 1405 | "beginCaptures": { 1406 | "0": { 1407 | "name": "punctuation.definition.begin.bracket.round.go" 1408 | } 1409 | }, 1410 | "end": "\\)", 1411 | "endCaptures": { 1412 | "0": { 1413 | "name": "punctuation.definition.end.bracket.round.go" 1414 | } 1415 | }, 1416 | "patterns": [ 1417 | { 1418 | "include": "#function_param_types" 1419 | } 1420 | ] 1421 | }, 1422 | { 1423 | "comment": "other types", 1424 | "match": "([\\w\\.]+)", 1425 | "captures": { 1426 | "1": { 1427 | "patterns": [ 1428 | { 1429 | "include": "#type-declarations" 1430 | }, 1431 | { 1432 | "match": "\\w+", 1433 | "name": "entity.name.type.go" 1434 | } 1435 | ] 1436 | } 1437 | } 1438 | }, 1439 | { 1440 | "include": "$self" 1441 | } 1442 | ] 1443 | }, 1444 | "generic_param_types": { 1445 | "comment": "generic parameter variables and types", 1446 | "patterns": [ 1447 | { 1448 | "include": "#struct_variables_types" 1449 | }, 1450 | { 1451 | "include": "#interface_variables_types" 1452 | }, 1453 | { 1454 | "include": "#type-declarations-without-brackets" 1455 | }, 1456 | { 1457 | "comment": "struct/interface type declaration", 1458 | "match": "((?:(?:\\b\\w+\\,\\s*)+)?\\b\\w+)\\s+(?=(?:(?:\\s*(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?(?:[\\[\\]\\*]+)?\\b(?:struct|interface)\\b\\s*\\{)", 1459 | "captures": { 1460 | "1": { 1461 | "patterns": [ 1462 | { 1463 | "include": "#type-declarations" 1464 | }, 1465 | { 1466 | "match": "\\w+", 1467 | "name": "variable.parameter.go" 1468 | } 1469 | ] 1470 | } 1471 | } 1472 | }, 1473 | { 1474 | "comment": "multiple parameters one type -with multilines", 1475 | "match": "(?:(?:(?<=\\()|^\\s*)((?:(?:\\b\\w+\\,\\s*)+)(?:\/(?:\/|\\*).*)?)$)", 1476 | "captures": { 1477 | "1": { 1478 | "patterns": [ 1479 | { 1480 | "include": "#type-declarations" 1481 | }, 1482 | { 1483 | "match": "\\w+", 1484 | "name": "variable.parameter.go" 1485 | } 1486 | ] 1487 | } 1488 | } 1489 | }, 1490 | { 1491 | "comment": "multiple params and types | multiple types one param", 1492 | "match": "(?:((?:(?:\\b\\w+\\,\\s*)+)?\\b\\w+)(?:\\s+)((?:(?:\\s*(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?(?:(?:(?:[\\w\\[\\]\\.\\*]+)?(?:(?:\\bfunc\\b\\((?:[^\\)]+)?\\))(?:(?:\\s*(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?(?:\\s*))+(?:(?:(?:[\\w\\*\\.]+)|(?:\\((?:[^\\)]+)?\\))))?)|(?:(?:(?:[\\w\\*\\.\\~]+)|(?:\\[(?:(?:[\\w\\.\\*]+)?(?:\\[(?:[^\\]]+)?\\])?(?:\\,\\s+)?)+\\]))(?:[\\w\\.\\*]+)?)+)))", 1493 | "captures": { 1494 | "1": { 1495 | "patterns": [ 1496 | { 1497 | "include": "#delimiters" 1498 | }, 1499 | { 1500 | "match": "\\w+", 1501 | "name": "variable.parameter.go" 1502 | } 1503 | ] 1504 | }, 1505 | "2": { 1506 | "patterns": [ 1507 | { 1508 | "include": "#type-declarations-without-brackets" 1509 | }, 1510 | { 1511 | "include": "#parameter-variable-types" 1512 | }, 1513 | { 1514 | "match": "\\w+", 1515 | "name": "entity.name.type.go" 1516 | } 1517 | ] 1518 | }, 1519 | "3": { 1520 | "patterns": [ 1521 | { 1522 | "include": "#type-declarations" 1523 | }, 1524 | { 1525 | "match": "\\w+", 1526 | "name": "entity.name.type.go" 1527 | } 1528 | ] 1529 | } 1530 | } 1531 | }, 1532 | { 1533 | "begin": "([\\w\\.\\*]+)?(\\[)", 1534 | "beginCaptures": { 1535 | "1": { 1536 | "patterns": [ 1537 | { 1538 | "include": "#type-declarations" 1539 | }, 1540 | { 1541 | "match": "\\w+", 1542 | "name": "entity.name.type.go" 1543 | } 1544 | ] 1545 | }, 1546 | "2": { 1547 | "name": "punctuation.definition.begin.bracket.square.go" 1548 | } 1549 | }, 1550 | "end": "\\]", 1551 | "endCaptures": { 1552 | "0": { 1553 | "name": "punctuation.definition.end.bracket.square.go" 1554 | } 1555 | }, 1556 | "patterns": [ 1557 | { 1558 | "include": "#generic_param_types" 1559 | } 1560 | ] 1561 | }, 1562 | { 1563 | "begin": "\\(", 1564 | "beginCaptures": { 1565 | "0": { 1566 | "name": "punctuation.definition.begin.bracket.round.go" 1567 | } 1568 | }, 1569 | "end": "\\)", 1570 | "endCaptures": { 1571 | "0": { 1572 | "name": "punctuation.definition.end.bracket.round.go" 1573 | } 1574 | }, 1575 | "patterns": [ 1576 | { 1577 | "include": "#function_param_types" 1578 | } 1579 | ] 1580 | }, 1581 | { 1582 | "comment": "other types", 1583 | "match": "\\b([\\w\\.]+)", 1584 | "captures": { 1585 | "1": { 1586 | "patterns": [ 1587 | { 1588 | "include": "#type-declarations" 1589 | }, 1590 | { 1591 | "match": "\\w+", 1592 | "name": "entity.name.type.go" 1593 | } 1594 | ] 1595 | } 1596 | } 1597 | }, 1598 | { 1599 | "include": "$self" 1600 | } 1601 | ] 1602 | }, 1603 | "functions": { 1604 | "comment": "Functions", 1605 | "begin": "(\\bfunc\\b)(?=\\()", 1606 | "beginCaptures": { 1607 | "1": { 1608 | "name": "keyword.function.go" 1609 | } 1610 | }, 1611 | "end": "(?:(?<=\\))(\\s*(?:(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?((?:(?:\\s*(?:(?:[\\[\\]\\*]+)?[\\w\\.\\*]+)?(?:(?:\\[(?:(?:[\\w\\.\\*]+)?(?:\\[(?:[^\\]]+)?\\])?(?:\\,\\s+)?)+\\])|(?:\\((?:[^\\)]+)?\\)))?(?:[\\w\\.\\*]+)?)(?:\\s*)(?=\\{))|(?:\\s*(?:(?:(?:[\\[\\]\\*]+)?(?!\\bfunc\\b)(?:[\\w\\.\\*]+)(?:\\[(?:(?:[\\w\\.\\*]+)?(?:\\[(?:[^\\]]+)?\\])?(?:\\,\\s+)?)+\\])?(?:[\\w\\.\\*]+)?)|(?:\\((?:[^\\)]+)?\\)))))?)", 1612 | "endCaptures": { 1613 | "1": { 1614 | "patterns": [ 1615 | { 1616 | "include": "#type-declarations" 1617 | } 1618 | ] 1619 | }, 1620 | "2": { 1621 | "patterns": [ 1622 | { 1623 | "include": "#type-declarations-without-brackets" 1624 | }, 1625 | { 1626 | "include": "#parameter-variable-types" 1627 | }, 1628 | { 1629 | "match": "\\w+", 1630 | "name": "entity.name.type.go" 1631 | } 1632 | ] 1633 | } 1634 | }, 1635 | "patterns": [ 1636 | { 1637 | "include": "#parameter-variable-types" 1638 | } 1639 | ] 1640 | }, 1641 | "functions_inline": { 1642 | "comment": "functions in-line with multi return types", 1643 | "match": "(?:(\\bfunc\\b)((?:\\((?:[^\/]*?)\\))(?:\\s+)(?:\\((?:[^\/]*?)\\)))(?:\\s+)(?=\\{))", 1644 | "captures": { 1645 | "1": { 1646 | "name": "keyword.function.go" 1647 | }, 1648 | "2": { 1649 | "patterns": [ 1650 | { 1651 | "include": "#type-declarations-without-brackets" 1652 | }, 1653 | { 1654 | "begin": "\\(", 1655 | "beginCaptures": { 1656 | "0": { 1657 | "name": "punctuation.definition.begin.bracket.round.go" 1658 | } 1659 | }, 1660 | "end": "\\)", 1661 | "endCaptures": { 1662 | "0": { 1663 | "name": "punctuation.definition.end.bracket.round.go" 1664 | } 1665 | }, 1666 | "patterns": [ 1667 | { 1668 | "include": "#function_param_types" 1669 | }, 1670 | { 1671 | "include": "$self" 1672 | } 1673 | ] 1674 | }, 1675 | { 1676 | "match": "\\[", 1677 | "name": "punctuation.definition.begin.bracket.square.go" 1678 | }, 1679 | { 1680 | "match": "\\]", 1681 | "name": "punctuation.definition.end.bracket.square.go" 1682 | }, 1683 | { 1684 | "match": "\\{", 1685 | "name": "punctuation.definition.begin.bracket.curly.go" 1686 | }, 1687 | { 1688 | "match": "\\}", 1689 | "name": "punctuation.definition.end.bracket.curly.go" 1690 | }, 1691 | { 1692 | "match": "\\w+", 1693 | "name": "entity.name.type.go" 1694 | } 1695 | ] 1696 | } 1697 | } 1698 | }, 1699 | "support_functions": { 1700 | "comment": "Support Functions", 1701 | "match": "(?:(?:((?<=\\.)\\b\\w+)|(\\b\\w+))(\\[(?:(?:[\\w\\.\\*\\[\\]\\{\\}\"\\']+)(?:(?:\\,\\s*(?:[\\w\\.\\*\\[\\]\\{\\}]+))*))?\\])?(?=\\())", 1702 | "captures": { 1703 | "1": { 1704 | "name": "entity.name.function.support.go" 1705 | }, 1706 | "2": { 1707 | "patterns": [ 1708 | { 1709 | "include": "#type-declarations" 1710 | }, 1711 | { 1712 | "match": "\\d\\w*", 1713 | "name": "invalid.illegal.identifier.go" 1714 | }, 1715 | { 1716 | "match": "\\w+", 1717 | "name": "entity.name.function.support.go" 1718 | } 1719 | ] 1720 | }, 1721 | "3": { 1722 | "patterns": [ 1723 | { 1724 | "include": "#type-declarations-without-brackets" 1725 | }, 1726 | { 1727 | "match": "\\[", 1728 | "name": "punctuation.definition.begin.bracket.square.go" 1729 | }, 1730 | { 1731 | "match": "\\]", 1732 | "name": "punctuation.definition.end.bracket.square.go" 1733 | }, 1734 | { 1735 | "match": "\\{", 1736 | "name": "punctuation.definition.begin.bracket.curly.go" 1737 | }, 1738 | { 1739 | "match": "\\}", 1740 | "name": "punctuation.definition.end.bracket.curly.go" 1741 | }, 1742 | { 1743 | "match": "\\w+", 1744 | "name": "entity.name.type.go" 1745 | } 1746 | ] 1747 | } 1748 | } 1749 | }, 1750 | "other_struct_interface_expressions": { 1751 | "comment": "struct and interface expression in-line (before curly bracket)", 1752 | "patterns": [ 1753 | { 1754 | "comment": "after control variables must be added exactly here, do not move it! (changing may not affect tests, so be careful!)", 1755 | "include": "#after_control_variables" 1756 | }, 1757 | { 1758 | "match": "(\\b[\\w\\.]+)(\\[(?:(?:[\\w\\.\\*\\[\\]\\{\\}]+)(?:(?:\\,\\s*(?:[\\w\\.\\*\\[\\]\\{\\}]+))*))?\\])?(?=\\{)(?|\\<\\=|\\>\\=|\\=\\=|\\!\\=|\\w(?:\\+|\/|\\-|\\*|\\%)|\\w(?:\\+|\/|\\-|\\*|\\%)\\=|\\|\\||\\&\\&)(?:\\s*)((?![\\[\\]]+)[[:alnum:]\\-\\_\\!\\.\\[\\]\\<\\>\\=\\*\/\\+\\%\\:]+)(?:\\s*)(?=\\{))", 2412 | "captures": { 2413 | "1": { 2414 | "patterns": [ 2415 | { 2416 | "include": "#type-declarations-without-brackets" 2417 | }, 2418 | { 2419 | "match": "\\[", 2420 | "name": "punctuation.definition.begin.bracket.square.go" 2421 | }, 2422 | { 2423 | "match": "\\]", 2424 | "name": "punctuation.definition.end.bracket.square.go" 2425 | }, 2426 | { 2427 | "match": "\\w+", 2428 | "name": "variable.other.go" 2429 | } 2430 | ] 2431 | } 2432 | } 2433 | }, 2434 | "syntax_errors": { 2435 | "patterns": [ 2436 | { 2437 | "comment": "Syntax error using slices", 2438 | "match": "\\[\\](\\s+)", 2439 | "captures": { 2440 | "1": { 2441 | "name": "invalid.illegal.slice.go" 2442 | } 2443 | } 2444 | }, 2445 | { 2446 | "comment": "Syntax error numeric literals", 2447 | "match": "\\b0[0-7]*[89]\\d*\\b", 2448 | "name": "invalid.illegal.numeric.go" 2449 | } 2450 | ] 2451 | }, 2452 | "built_in_functions": { 2453 | "comment": "Built-in functions", 2454 | "patterns": [ 2455 | { 2456 | "match": "\\b(append|cap|close|complex|copy|delete|imag|len|panic|print|println|real|recover|min|max|clear)\\b(?=\\()", 2457 | "name": "entity.name.function.support.builtin.go" 2458 | }, 2459 | { 2460 | "comment": "new keyword", 2461 | "begin": "(\\bnew\\b)(\\()", 2462 | "beginCaptures": { 2463 | "1": { 2464 | "name": "entity.name.function.support.builtin.go" 2465 | }, 2466 | "2": { 2467 | "name": "punctuation.definition.begin.bracket.round.go" 2468 | } 2469 | }, 2470 | "end": "\\)", 2471 | "endCaptures": { 2472 | "0": { 2473 | "name": "punctuation.definition.end.bracket.round.go" 2474 | } 2475 | }, 2476 | "patterns": [ 2477 | { 2478 | "include": "#functions" 2479 | }, 2480 | { 2481 | "include": "#struct_variables_types" 2482 | }, 2483 | { 2484 | "include": "#type-declarations" 2485 | }, 2486 | { 2487 | "include": "#generic_types" 2488 | }, 2489 | { 2490 | "match": "\\w+", 2491 | "name": "entity.name.type.go" 2492 | }, 2493 | { 2494 | "include": "$self" 2495 | } 2496 | ] 2497 | }, 2498 | { 2499 | "comment": "make keyword", 2500 | "begin": "(?:(\\bmake\\b)(?:(\\()((?:(?:(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+(?:\\([^\\)]+\\))?)?(?:[\\[\\]\\*]+)?(?:(?!\\bmap\\b)(?:[\\w\\.]+))?(\\[(?:(?:[\\S]+)(?:(?:\\,\\s*(?:[\\S]+))*))?\\])?(?:\\,)?)?))", 2501 | "beginCaptures": { 2502 | "1": { 2503 | "name": "entity.name.function.support.builtin.go" 2504 | }, 2505 | "2": { 2506 | "name": "punctuation.definition.begin.bracket.round.go" 2507 | }, 2508 | "3": { 2509 | "patterns": [ 2510 | { 2511 | "include": "#type-declarations-without-brackets" 2512 | }, 2513 | { 2514 | "include": "#parameter-variable-types" 2515 | }, 2516 | { 2517 | "match": "\\w+", 2518 | "name": "entity.name.type.go" 2519 | } 2520 | ] 2521 | } 2522 | }, 2523 | "end": "\\)", 2524 | "endCaptures": { 2525 | "0": { 2526 | "name": "punctuation.definition.end.bracket.round.go" 2527 | } 2528 | }, 2529 | "patterns": [ 2530 | { 2531 | "include": "$self" 2532 | } 2533 | ] 2534 | } 2535 | ] 2536 | }, 2537 | "struct_interface_declaration": { 2538 | "comment": "struct, interface type declarations (related to: struct_variables_types, interface_variables_types)", 2539 | "match": "(?:(?:^\\s*)(\\btype\\b)(?:\\s*)([\\w\\.]+))", 2540 | "captures": { 2541 | "1": { 2542 | "name": "keyword.type.go" 2543 | }, 2544 | "2": { 2545 | "patterns": [ 2546 | { 2547 | "include": "#type-declarations" 2548 | }, 2549 | { 2550 | "match": "\\w+", 2551 | "name": "entity.name.type.go" 2552 | } 2553 | ] 2554 | } 2555 | } 2556 | }, 2557 | "switch_types": { 2558 | "comment": "switch type assertions, only highlights types after case keyword", 2559 | "begin": "(?<=\\bswitch\\b)(?:\\s*)(?:(\\w+\\s*\\:\\=)?\\s*([\\w\\.\\*\\(\\)\\[\\]\\+\/\\-\\%\\<\\>\\|\\&]+))(\\.\\(\\btype\\b\\)\\s*)(\\{)", 2560 | "beginCaptures": { 2561 | "1": { 2562 | "patterns": [ 2563 | { 2564 | "include": "#operators" 2565 | }, 2566 | { 2567 | "match": "\\w+", 2568 | "name": "variable.other.assignment.go" 2569 | } 2570 | ] 2571 | }, 2572 | "2": { 2573 | "patterns": [ 2574 | { 2575 | "include": "#support_functions" 2576 | }, 2577 | { 2578 | "include": "#type-declarations" 2579 | }, 2580 | { 2581 | "match": "\\w+", 2582 | "name": "variable.other.go" 2583 | } 2584 | ] 2585 | }, 2586 | "3": { 2587 | "patterns": [ 2588 | { 2589 | "include": "#delimiters" 2590 | }, 2591 | { 2592 | "include": "#brackets" 2593 | }, 2594 | { 2595 | "match": "\\btype\\b", 2596 | "name": "keyword.type.go" 2597 | } 2598 | ] 2599 | }, 2600 | "4": { 2601 | "name": "punctuation.definition.begin.bracket.curly.go" 2602 | } 2603 | }, 2604 | "end": "\\}", 2605 | "endCaptures": { 2606 | "0": { 2607 | "name": "punctuation.definition.end.bracket.curly.go" 2608 | } 2609 | }, 2610 | "patterns": [ 2611 | { 2612 | "comment": "types after case keyword with single line", 2613 | "match": "(?:^\\s*(\\bcase\\b))(?:\\s+)([\\w\\.\\,\\*\\=\\<\\>\\!\\s]+)(:)(\\s*\/(?:\/|\\*)\\s*.*)?$", 2614 | "captures": { 2615 | "1": { 2616 | "name": "keyword.control.go" 2617 | }, 2618 | "2": { 2619 | "patterns": [ 2620 | { 2621 | "include": "#type-declarations" 2622 | }, 2623 | { 2624 | "match": "\\w+", 2625 | "name": "entity.name.type.go" 2626 | } 2627 | ] 2628 | }, 2629 | "3": { 2630 | "name": "punctuation.other.colon.go" 2631 | }, 2632 | "4": { 2633 | "patterns": [ 2634 | { 2635 | "include": "#comments" 2636 | } 2637 | ] 2638 | } 2639 | } 2640 | }, 2641 | { 2642 | "comment": "types after case keyword with multi lines", 2643 | "begin": "\\bcase\\b", 2644 | "beginCaptures": { 2645 | "0": { 2646 | "name": "keyword.control.go" 2647 | } 2648 | }, 2649 | "end": "\\:", 2650 | "endCaptures": { 2651 | "0": { 2652 | "name": "punctuation.other.colon.go" 2653 | } 2654 | }, 2655 | "patterns": [ 2656 | { 2657 | "include": "#type-declarations" 2658 | }, 2659 | { 2660 | "match": "\\w+", 2661 | "name": "entity.name.type.go" 2662 | } 2663 | ] 2664 | }, 2665 | { 2666 | "include": "$self" 2667 | } 2668 | ] 2669 | }, 2670 | "switch_variables": { 2671 | "comment": "variables after case control keyword in switch/select expression, to not scope them as property variables", 2672 | "patterns": [ 2673 | { 2674 | "comment": "single line", 2675 | "match": "(?:(?:^\\s*(\\bcase\\b))(?:\\s+)([\\s\\S]+(?:\\:)\\s*(?:\/(?:\/|\\*).*)?)$)", 2676 | "captures": { 2677 | "1": { 2678 | "name": "keyword.control.go" 2679 | }, 2680 | "2": { 2681 | "patterns": [ 2682 | { 2683 | "include": "#type-declarations" 2684 | }, 2685 | { 2686 | "include": "#support_functions" 2687 | }, 2688 | { 2689 | "include": "#variable_assignment" 2690 | }, 2691 | { 2692 | "match": "\\w+", 2693 | "name": "variable.other.go" 2694 | } 2695 | ] 2696 | } 2697 | } 2698 | }, 2699 | { 2700 | "comment": "multi lines", 2701 | "begin": "(?<=\\bswitch\\b)(?:\\s*)((?:[\\w\\.]+(?:\\s*(?:[\\:\\=\\!\\,\\+\/\\-\\%\\<\\>\\|\\&]+)\\s*[\\w\\.]+)*\\s*(?:[\\:\\=\\!\\,\\+\/\\-\\%\\<\\>\\|\\&]+))?(?:\\s*(?:[\\w\\.\\*\\(\\)\\[\\]\\+\/\\-\\%\\<\\>\\|\\&]+)?\\s*(?:\\;\\s*(?:[\\w\\.\\*\\(\\)\\[\\]\\+\/\\-\\%\\<\\>\\|\\&]+)\\s*)?))(\\{)", 2702 | "beginCaptures": { 2703 | "1": { 2704 | "patterns": [ 2705 | { 2706 | "include": "#support_functions" 2707 | }, 2708 | { 2709 | "include": "#type-declarations" 2710 | }, 2711 | { 2712 | "include": "#variable_assignment" 2713 | }, 2714 | { 2715 | "match": "\\w+", 2716 | "name": "variable.other.go" 2717 | } 2718 | ] 2719 | }, 2720 | "2": { 2721 | "name": "punctuation.definition.begin.bracket.curly.go" 2722 | } 2723 | }, 2724 | "end": "\\}", 2725 | "endCaptures": { 2726 | "0": { 2727 | "name": "punctuation.definition.end.bracket.curly.go" 2728 | } 2729 | }, 2730 | "patterns": [ 2731 | { 2732 | "begin": "\\bcase\\b", 2733 | "beginCaptures": { 2734 | "0": { 2735 | "name": "keyword.control.go" 2736 | } 2737 | }, 2738 | "end": "\\:", 2739 | "endCaptures": { 2740 | "0": { 2741 | "name": "punctuation.other.colon.go" 2742 | } 2743 | }, 2744 | "patterns": [ 2745 | { 2746 | "include": "#support_functions" 2747 | }, 2748 | { 2749 | "include": "#type-declarations" 2750 | }, 2751 | { 2752 | "include": "#variable_assignment" 2753 | }, 2754 | { 2755 | "match": "\\w+", 2756 | "name": "variable.other.go" 2757 | } 2758 | ] 2759 | }, 2760 | { 2761 | "include": "$self" 2762 | } 2763 | ] 2764 | } 2765 | ] 2766 | }, 2767 | "var_assignment": { 2768 | "comment": "variable assignment with var keyword", 2769 | "patterns": [ 2770 | { 2771 | "comment": "single assignment", 2772 | "match": "(?:(?<=\\bvar\\b)(?:\\s*)(\\b[\\w\\.]+(?:\\,\\s*[\\w\\.]+)*)(?:\\s*)((?:(?:(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+(?:\\([^\\)]+\\))?)?(?!(?:[\\[\\]\\*]+)?\\b(?:struct|func|map)\\b)(?:[\\w\\.\\[\\]\\*]+(?:\\,\\s*[\\w\\.\\[\\]\\*]+)*)?(?:\\s*)(?:\\=)?)?)", 2773 | "captures": { 2774 | "1": { 2775 | "patterns": [ 2776 | { 2777 | "include": "#delimiters" 2778 | }, 2779 | { 2780 | "match": "\\w+", 2781 | "name": "variable.other.assignment.go" 2782 | } 2783 | ] 2784 | }, 2785 | "2": { 2786 | "patterns": [ 2787 | { 2788 | "include": "#type-declarations-without-brackets" 2789 | }, 2790 | { 2791 | "include": "#generic_types" 2792 | }, 2793 | { 2794 | "match": "\\(", 2795 | "name": "punctuation.definition.begin.bracket.round.go" 2796 | }, 2797 | { 2798 | "match": "\\)", 2799 | "name": "punctuation.definition.end.bracket.round.go" 2800 | }, 2801 | { 2802 | "match": "\\[", 2803 | "name": "punctuation.definition.begin.bracket.square.go" 2804 | }, 2805 | { 2806 | "match": "\\]", 2807 | "name": "punctuation.definition.end.bracket.square.go" 2808 | }, 2809 | { 2810 | "match": "\\w+", 2811 | "name": "entity.name.type.go" 2812 | } 2813 | ] 2814 | } 2815 | } 2816 | }, 2817 | { 2818 | "comment": "multi assignment", 2819 | "begin": "(?:(?<=\\bvar\\b)(?:\\s*)(\\())", 2820 | "beginCaptures": { 2821 | "1": { 2822 | "name": "punctuation.definition.begin.bracket.round.go" 2823 | } 2824 | }, 2825 | "end": "\\)", 2826 | "endCaptures": { 2827 | "0": { 2828 | "name": "punctuation.definition.end.bracket.round.go" 2829 | } 2830 | }, 2831 | "patterns": [ 2832 | { 2833 | "match": "(?:(?:^\\s*)(\\b[\\w\\.]+(?:\\,\\s*[\\w\\.]+)*)(?:\\s*)((?:(?:(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+(?:\\([^\\)]+\\))?)?(?!(?:[\\[\\]\\*]+)?\\b(?:struct|func|map)\\b)(?:[\\w\\.\\[\\]\\*]+(?:\\,\\s*[\\w\\.\\[\\]\\*]+)*)?(?:\\s*)(?:\\=)?)?)", 2834 | "captures": { 2835 | "1": { 2836 | "patterns": [ 2837 | { 2838 | "include": "#delimiters" 2839 | }, 2840 | { 2841 | "match": "\\w+", 2842 | "name": "variable.other.assignment.go" 2843 | } 2844 | ] 2845 | }, 2846 | "2": { 2847 | "patterns": [ 2848 | { 2849 | "include": "#type-declarations-without-brackets" 2850 | }, 2851 | { 2852 | "include": "#generic_types" 2853 | }, 2854 | { 2855 | "match": "\\(", 2856 | "name": "punctuation.definition.begin.bracket.round.go" 2857 | }, 2858 | { 2859 | "match": "\\)", 2860 | "name": "punctuation.definition.end.bracket.round.go" 2861 | }, 2862 | { 2863 | "match": "\\[", 2864 | "name": "punctuation.definition.begin.bracket.square.go" 2865 | }, 2866 | { 2867 | "match": "\\]", 2868 | "name": "punctuation.definition.end.bracket.square.go" 2869 | }, 2870 | { 2871 | "match": "\\w+", 2872 | "name": "entity.name.type.go" 2873 | } 2874 | ] 2875 | } 2876 | } 2877 | }, 2878 | { 2879 | "include": "$self" 2880 | } 2881 | ] 2882 | } 2883 | ] 2884 | }, 2885 | "const_assignment": { 2886 | "comment": "constant assignment with const keyword", 2887 | "patterns": [ 2888 | { 2889 | "comment": "single assignment", 2890 | "match": "(?:(?<=\\bconst\\b)(?:\\s*)(\\b[\\w\\.]+(?:\\,\\s*[\\w\\.]+)*)(?:\\s*)((?:(?:(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+(?:\\([^\\)]+\\))?)?(?!(?:[\\[\\]\\*]+)?\\b(?:struct|func|map)\\b)(?:[\\w\\.\\[\\]\\*]+(?:\\,\\s*[\\w\\.\\[\\]\\*]+)*)?(?:\\s*)(?:\\=)?)?)", 2891 | "captures": { 2892 | "1": { 2893 | "patterns": [ 2894 | { 2895 | "include": "#delimiters" 2896 | }, 2897 | { 2898 | "match": "\\w+", 2899 | "name": "variable.other.constant.go" 2900 | } 2901 | ] 2902 | }, 2903 | "2": { 2904 | "patterns": [ 2905 | { 2906 | "include": "#type-declarations-without-brackets" 2907 | }, 2908 | { 2909 | "include": "#generic_types" 2910 | }, 2911 | { 2912 | "match": "\\(", 2913 | "name": "punctuation.definition.begin.bracket.round.go" 2914 | }, 2915 | { 2916 | "match": "\\)", 2917 | "name": "punctuation.definition.end.bracket.round.go" 2918 | }, 2919 | { 2920 | "match": "\\[", 2921 | "name": "punctuation.definition.begin.bracket.square.go" 2922 | }, 2923 | { 2924 | "match": "\\]", 2925 | "name": "punctuation.definition.end.bracket.square.go" 2926 | }, 2927 | { 2928 | "match": "\\w+", 2929 | "name": "entity.name.type.go" 2930 | } 2931 | ] 2932 | } 2933 | } 2934 | }, 2935 | { 2936 | "comment": "multi assignment", 2937 | "begin": "(?:(?<=\\bconst\\b)(?:\\s*)(\\())", 2938 | "beginCaptures": { 2939 | "1": { 2940 | "name": "punctuation.definition.begin.bracket.round.go" 2941 | } 2942 | }, 2943 | "end": "\\)", 2944 | "endCaptures": { 2945 | "0": { 2946 | "name": "punctuation.definition.end.bracket.round.go" 2947 | } 2948 | }, 2949 | "patterns": [ 2950 | { 2951 | "match": "(?:(?:^\\s*)(\\b[\\w\\.]+(?:\\,\\s*[\\w\\.]+)*)(?:\\s*)((?:(?:(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+(?:\\([^\\)]+\\))?)?(?!(?:[\\[\\]\\*]+)?\\b(?:struct|func|map)\\b)(?:[\\w\\.\\[\\]\\*]+(?:\\,\\s*[\\w\\.\\[\\]\\*]+)*)?(?:\\s*)(?:\\=)?)?)", 2952 | "captures": { 2953 | "1": { 2954 | "patterns": [ 2955 | { 2956 | "include": "#delimiters" 2957 | }, 2958 | { 2959 | "match": "\\w+", 2960 | "name": "variable.other.constant.go" 2961 | } 2962 | ] 2963 | }, 2964 | "2": { 2965 | "patterns": [ 2966 | { 2967 | "include": "#type-declarations-without-brackets" 2968 | }, 2969 | { 2970 | "include": "#generic_types" 2971 | }, 2972 | { 2973 | "match": "\\(", 2974 | "name": "punctuation.definition.begin.bracket.round.go" 2975 | }, 2976 | { 2977 | "match": "\\)", 2978 | "name": "punctuation.definition.end.bracket.round.go" 2979 | }, 2980 | { 2981 | "match": "\\[", 2982 | "name": "punctuation.definition.begin.bracket.square.go" 2983 | }, 2984 | { 2985 | "match": "\\]", 2986 | "name": "punctuation.definition.end.bracket.square.go" 2987 | }, 2988 | { 2989 | "match": "\\w+", 2990 | "name": "entity.name.type.go" 2991 | } 2992 | ] 2993 | } 2994 | } 2995 | }, 2996 | { 2997 | "include": "$self" 2998 | } 2999 | ] 3000 | } 3001 | ] 3002 | }, 3003 | "variable_assignment": { 3004 | "comment": "variable assignment", 3005 | "patterns": [ 3006 | { 3007 | "comment": "variable assignment with :=", 3008 | "match": "\\b\\w+(?:\\,\\s*\\w+)*(?=\\s*:=)", 3009 | "captures": { 3010 | "0": { 3011 | "patterns": [ 3012 | { 3013 | "include": "#delimiters" 3014 | }, 3015 | { 3016 | "match": "\\d\\w*", 3017 | "name": "invalid.illegal.identifier.go" 3018 | }, 3019 | { 3020 | "match": "\\w+", 3021 | "name": "variable.other.assignment.go" 3022 | } 3023 | ] 3024 | } 3025 | } 3026 | }, 3027 | { 3028 | "comment": "variable assignment with =", 3029 | "match": "\\b[\\w\\.\\*]+(?:\\,\\s*[\\w\\.\\*]+)*(?=\\s*=(?!=))", 3030 | "captures": { 3031 | "0": { 3032 | "patterns": [ 3033 | { 3034 | "include": "#delimiters" 3035 | }, 3036 | { 3037 | "include": "#operators" 3038 | }, 3039 | { 3040 | "match": "\\d\\w*", 3041 | "name": "invalid.illegal.identifier.go" 3042 | }, 3043 | { 3044 | "match": "\\w+", 3045 | "name": "variable.other.assignment.go" 3046 | } 3047 | ] 3048 | } 3049 | } 3050 | } 3051 | ] 3052 | }, 3053 | "generic_types": { 3054 | "comment": "Generic support for all types", 3055 | "match": "(?:([\\w\\.\\*]+)(\\[(?:[^\\]]+)?\\]))", 3056 | "captures": { 3057 | "1": { 3058 | "patterns": [ 3059 | { 3060 | "include": "#type-declarations" 3061 | }, 3062 | { 3063 | "match": "\\w+", 3064 | "name": "entity.name.type.go" 3065 | } 3066 | ] 3067 | }, 3068 | "2": { 3069 | "patterns": [ 3070 | { 3071 | "include": "#parameter-variable-types" 3072 | } 3073 | ] 3074 | } 3075 | } 3076 | }, 3077 | "slice_index_variables": { 3078 | "comment": "slice index and capacity variables, to not scope them as property variables", 3079 | "match": "(?<=\\w\\[)((?:(?:\\b[\\w\\.\\*\\+\/\\-\\%\\<\\>\\|\\&]+\\:)|(?:\\:\\b[\\w\\.\\*\\+\/\\-\\%\\<\\>\\|\\&]+))(?:\\b[\\w\\.\\*\\+\/\\-\\%\\<\\>\\|\\&]+)?(?:\\:\\b[\\w\\.\\*\\+\/\\-\\%\\<\\>\\|\\&]+)?)(?=\\])", 3080 | "captures": { 3081 | "1": { 3082 | "patterns": [ 3083 | { 3084 | "include": "#type-declarations" 3085 | }, 3086 | { 3087 | "match": "\\w+", 3088 | "name": "variable.other.go" 3089 | } 3090 | ] 3091 | } 3092 | } 3093 | }, 3094 | "property_variables": { 3095 | "comment": "Property variables in struct", 3096 | "match": "((?:\\b[\\w\\.]+)(?:\\:(?!\\=)))", 3097 | "captures": { 3098 | "1": { 3099 | "patterns": [ 3100 | { 3101 | "include": "#type-declarations" 3102 | }, 3103 | { 3104 | "match": "\\w+", 3105 | "name": "variable.other.property.go" 3106 | } 3107 | ] 3108 | } 3109 | } 3110 | }, 3111 | "label_loop_variables": { 3112 | "comment": "labeled loop variable name", 3113 | "match": "((?:^\\s*\\w+:\\s*$)|(?:^\\s*(?:\\bbreak\\b|\\bgoto\\b|\\bcontinue\\b)\\s+\\w+(?:\\s*\/(?:\/|\\*)\\s*.*)?$))", 3114 | "captures": { 3115 | "1": { 3116 | "patterns": [ 3117 | { 3118 | "include": "#type-declarations" 3119 | }, 3120 | { 3121 | "match": "\\w+", 3122 | "name": "variable.other.label.go" 3123 | } 3124 | ] 3125 | } 3126 | } 3127 | }, 3128 | "double_parentheses_types": { 3129 | "comment": "double parentheses types", 3130 | "match": "(?:(?