Skip to content

Commit f8bb386

Browse files
authored
Update grammars (microsoft#254634)
1 parent a31b87c commit f8bb386

File tree

12 files changed

+214
-90
lines changed

12 files changed

+214
-90
lines changed

extensions/go/cgmanifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
"git": {
77
"name": "go-syntax",
88
"repositoryUrl": "https://github.com/worlpaker/go-syntax",
9-
"commitHash": "0ce19cdf1cb5dab6aa99ccc933be9bd21e855ed1"
9+
"commitHash": "8c70c078f56d237f72574ce49cc95839c4f8a741"
1010
}
1111
},
1212
"license": "MIT",
1313
"description": "The file syntaxes/go.tmLanguage.json is from https://github.com/worlpaker/go-syntax, which in turn was derived from https://github.com/jeff-hykin/better-go-syntax.",
14-
"version": "0.8.1"
14+
"version": "0.8.4"
1515
}
1616
],
1717
"version": 1

extensions/go/syntaxes/go.tmLanguage.json

Lines changed: 190 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
55
"Once accepted there, we are happy to receive an update request."
66
],
7-
"version": "https://github.com/worlpaker/go-syntax/commit/0ce19cdf1cb5dab6aa99ccc933be9bd21e855ed1",
7+
"version": "https://github.com/worlpaker/go-syntax/commit/8c70c078f56d237f72574ce49cc95839c4f8a741",
88
"name": "Go",
99
"scopeName": "source.go",
1010
"patterns": [
@@ -34,7 +34,7 @@
3434
"include": "#group-variables"
3535
},
3636
{
37-
"include": "#field_hover"
37+
"include": "#hover"
3838
}
3939
]
4040
},
@@ -115,7 +115,7 @@
115115
"include": "#property_variables"
116116
},
117117
{
118-
"include": "#switch_select_case_variables"
118+
"include": "#switch_variables"
119119
},
120120
{
121121
"include": "#other_variables"
@@ -1704,7 +1704,7 @@
17041704
},
17051705
"support_functions": {
17061706
"comment": "Support Functions",
1707-
"match": "(?:(?:((?<=\\.)\\b\\w+)|(\\b\\w+))(\\[(?:(?:[\\w\\.\\*\\[\\]\\{\\}\"\\']+)(?:(?:\\,\\s*(?:[\\w\\.\\*\\[\\]\\{\\}]+))*))?\\])?(?=\\())",
1707+
"match": "(?:(?:((?<=\\.)\\b\\w+)|(\\b\\w+))(?<brackets>\\[(?:[^\\[\\]]|\\g<brackets>)*\\])?(?=\\())",
17081708
"captures": {
17091709
"1": {
17101710
"name": "entity.name.function.support.go"
@@ -1761,7 +1761,8 @@
17611761
"include": "#after_control_variables"
17621762
},
17631763
{
1764-
"match": "(\\b[\\w\\.]+)(\\[(?:(?:[\\w\\.\\*\\[\\]\\{\\}]+)(?:(?:\\,\\s*(?:[\\w\\.\\*\\[\\]\\{\\}]+))*))?\\])?(?=\\{)(?<!\\bstruct\\b|\\binterface\\b)",
1764+
"comment": "uses a named group to recursively match generic type with nested brackets, like 'Foo[A[B, C]]{}'",
1765+
"match": "\\b(?!struct\\b|interface\\b)([\\w\\.]+)(?<brackets>\\[(?:[^\\[\\]]|\\g<brackets>)*\\])?(?=\\{)",
17651766
"captures": {
17661767
"1": {
17671768
"patterns": [
@@ -1807,15 +1808,39 @@
18071808
},
18081809
"type_assertion_inline": {
18091810
"comment": "struct/interface types in-line (type assertion) | switch type keyword",
1810-
"match": "(?:(?<=\\.\\()(?:(\\btype\\b)|((?:(?:\\s*(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?[\\w\\.\\[\\]\\*]+))(?=\\)))",
1811+
"match": "(?:(?<=\\.\\()(?:(\\btype\\b)|((?:(?:\\s*(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?(?:[\\[\\]\\*]+)?(?:[\\w\\.]+)(?:\\[(?:(?:[\\w\\.\\*\\[\\]\\{\\}]+)(?:(?:\\,\\s*(?:[\\w\\.\\*\\[\\]\\{\\}]+))*))?\\])?))(?=\\)))",
18111812
"captures": {
18121813
"1": {
18131814
"name": "keyword.type.go"
18141815
},
18151816
"2": {
18161817
"patterns": [
18171818
{
1818-
"include": "#type-declarations"
1819+
"include": "#type-declarations-without-brackets"
1820+
},
1821+
{
1822+
"match": "\\(",
1823+
"name": "punctuation.definition.begin.bracket.round.go"
1824+
},
1825+
{
1826+
"match": "\\)",
1827+
"name": "punctuation.definition.end.bracket.round.go"
1828+
},
1829+
{
1830+
"match": "\\[",
1831+
"name": "punctuation.definition.begin.bracket.square.go"
1832+
},
1833+
{
1834+
"match": "\\]",
1835+
"name": "punctuation.definition.end.bracket.square.go"
1836+
},
1837+
{
1838+
"match": "\\{",
1839+
"name": "punctuation.definition.begin.bracket.curly.go"
1840+
},
1841+
{
1842+
"match": "\\}",
1843+
"name": "punctuation.definition.end.bracket.curly.go"
18191844
},
18201845
{
18211846
"match": "\\w+",
@@ -1904,12 +1929,12 @@
19041929
},
19051930
{
19061931
"comment": "one line with semicolon(;) without formatting gofmt - single type | property variables and types",
1907-
"match": "(?:(?<=\\{)((?:\\s*(?:(?:(?:\\w+\\,\\s*)+)?(?:\\w+\\s+))?(?:(?:(?:\\s*(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?(?:[\\S]+)(?:\\;)?))+)\\s*(?=\\}))",
1932+
"match": "(?:(?<=\\{)((?:\\s*(?:(?:(?:\\w+\\,\\s*)+)?(?:\\w+\\s+))?(?:(?:(?:\\s*(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?(?:[^\\s/]+)(?:\\;)?))+)\\s*(?=\\}))",
19081933
"captures": {
19091934
"1": {
19101935
"patterns": [
19111936
{
1912-
"match": "(?:((?:(?:\\w+\\,\\s*)+)?(?:\\w+\\s+))?((?:(?:\\s*(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?(?:[\\S]+)(?:\\;)?))",
1937+
"match": "(?:((?:(?:\\w+\\,\\s*)+)?(?:\\w+\\s+))?((?:(?:\\s*(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?(?:[^\\s/]+)(?:\\;)?))",
19131938
"captures": {
19141939
"1": {
19151940
"patterns": [
@@ -1958,7 +1983,7 @@
19581983
},
19591984
{
19601985
"comment": "property variables and types",
1961-
"match": "(?:((?:(?:\\w+\\,\\s*)+)?(?:\\w+\\s+))([^\\`\"\\/]+))",
1986+
"match": "(\\b\\w+(?:\\s*\\,\\s*\\b\\w+)*)\\s*([^\\`\"\\/]+)",
19621987
"captures": {
19631988
"1": {
19641989
"patterns": [
@@ -1994,7 +2019,7 @@
19942019
"patterns": [
19952020
{
19962021
"comment": "struct in struct types",
1997-
"begin": "(?:((?:\\w+(?:\\,\\s*\\w+)*)(?:(?:\\s*(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?(?:\\s+)(?:[\\[\\]\\*]+)?)(\\bstruct\\b)(?:\\s*)(\\{))",
2022+
"begin": "(?:((?:\\b\\w+(?:\\,\\s*\\b\\w+)*)(?:(?:\\s*(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?(?:\\s*)(?:[\\[\\]\\*]+)?)(\\bstruct\\b)(?:\\s*)(\\{))",
19982023
"beginCaptures": {
19992024
"1": {
20002025
"patterns": [
@@ -2031,7 +2056,7 @@
20312056
},
20322057
{
20332058
"comment": "interface in struct types",
2034-
"begin": "(?:((?:\\w+(?:\\,\\s*\\w+)*)(?:(?:\\s*(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?(?:\\s+)(?:[\\[\\]\\*]+)?)(\\binterface\\b)(?:\\s*)(\\{))",
2059+
"begin": "(?:((?:\\b\\w+(?:\\,\\s*\\b\\w+)*)(?:(?:\\s*(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?(?:\\s*)(?:[\\[\\]\\*]+)?)(\\binterface\\b)(?:\\s*)(\\{))",
20352060
"beginCaptures": {
20362061
"1": {
20372062
"patterns": [
@@ -2068,7 +2093,7 @@
20682093
},
20692094
{
20702095
"comment": "function in struct types",
2071-
"begin": "(?:((?:\\w+(?:\\,\\s*\\w+)*)(?:(?:\\s*(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?(?:\\s+)(?:[\\[\\]\\*]+)?)(\\bfunc\\b)(?:\\s*)(\\())",
2096+
"begin": "(?:((?:\\b\\w+(?:\\,\\s*\\b\\w+)*)(?:(?:\\s*(?:[\\*\\[\\]]+)?(?:\\<\\-\\s*)?\\bchan\\b(?:\\s*\\<\\-)?\\s*)+)?(?:\\s*)(?:[\\[\\]\\*]+)?)(\\bfunc\\b)(?:\\s*)(\\())",
20722097
"beginCaptures": {
20732098
"1": {
20742099
"patterns": [
@@ -2390,7 +2415,7 @@
23902415
},
23912416
"after_control_variables": {
23922417
"comment": "After control variables, to not highlight as a struct/interface (before formatting with gofmt)",
2393-
"match": "(?:(?<=\\brange\\b|\\bswitch\\b|\\;|\\bif\\b|\\bfor\\b|\\<|\\>|\\<\\=|\\>\\=|\\=\\=|\\!\\=|\\w(?:\\+|/|\\-|\\*|\\%)|\\w(?:\\+|/|\\-|\\*|\\%)\\=|\\|\\||\\&\\&)(?:\\s*)((?![\\[\\]]+)[[:alnum:]\\-\\_\\!\\.\\[\\]\\<\\>\\=\\*/\\+\\%\\:]+)(?:\\s*)(?=\\{))",
2418+
"match": "(?:(?<=\\brange\\b|\\;|\\bif\\b|\\bfor\\b|\\<|\\>|\\<\\=|\\>\\=|\\=\\=|\\!\\=|\\w(?:\\+|/|\\-|\\*|\\%)|\\w(?:\\+|/|\\-|\\*|\\%)\\=|\\|\\||\\&\\&)(?:\\s*)((?![\\[\\]]+)[[:alnum:]\\-\\_\\!\\.\\[\\]\\<\\>\\=\\*/\\+\\%\\:]+)(?:\\s*)(?=\\{))",
23942419
"captures": {
23952420
"1": {
23962421
"patterns": [
@@ -2649,6 +2674,103 @@
26492674
}
26502675
]
26512676
},
2677+
"switch_variables": {
2678+
"comment": "variables after case control keyword in switch/select expression, to not scope them as property variables",
2679+
"patterns": [
2680+
{
2681+
"comment": "single line",
2682+
"match": "(?:(?:^\\s*(\\bcase\\b))(?:\\s+)([\\s\\S]+(?:\\:)\\s*(?:/(?:/|\\*).*)?)$)",
2683+
"captures": {
2684+
"1": {
2685+
"name": "keyword.control.go"
2686+
},
2687+
"2": {
2688+
"patterns": [
2689+
{
2690+
"include": "#type-declarations"
2691+
},
2692+
{
2693+
"include": "#support_functions"
2694+
},
2695+
{
2696+
"include": "#variable_assignment"
2697+
},
2698+
{
2699+
"match": "\\w+",
2700+
"name": "variable.other.go"
2701+
}
2702+
]
2703+
}
2704+
}
2705+
},
2706+
{
2707+
"comment": "multi lines",
2708+
"begin": "(?<=\\bswitch\\b)(?:\\s*)((?:[\\w\\.]+(?:\\s*(?:[\\:\\=\\!\\,\\+/\\-\\%\\<\\>\\|\\&]+)\\s*[\\w\\.]+)*\\s*(?:[\\:\\=\\!\\,\\+/\\-\\%\\<\\>\\|\\&]+))?(?:\\s*(?:[\\w\\.\\*\\(\\)\\[\\]\\+/\\-\\%\\<\\>\\|\\&]+)?\\s*(?:\\;\\s*(?:[\\w\\.\\*\\(\\)\\[\\]\\+/\\-\\%\\<\\>\\|\\&]+)\\s*)?))(\\{)",
2709+
"beginCaptures": {
2710+
"1": {
2711+
"patterns": [
2712+
{
2713+
"include": "#support_functions"
2714+
},
2715+
{
2716+
"include": "#type-declarations"
2717+
},
2718+
{
2719+
"include": "#variable_assignment"
2720+
},
2721+
{
2722+
"match": "\\w+",
2723+
"name": "variable.other.go"
2724+
}
2725+
]
2726+
},
2727+
"2": {
2728+
"name": "punctuation.definition.begin.bracket.curly.go"
2729+
}
2730+
},
2731+
"end": "\\}",
2732+
"endCaptures": {
2733+
"0": {
2734+
"name": "punctuation.definition.end.bracket.curly.go"
2735+
}
2736+
},
2737+
"patterns": [
2738+
{
2739+
"begin": "\\bcase\\b",
2740+
"beginCaptures": {
2741+
"0": {
2742+
"name": "keyword.control.go"
2743+
}
2744+
},
2745+
"end": "\\:",
2746+
"endCaptures": {
2747+
"0": {
2748+
"name": "punctuation.other.colon.go"
2749+
}
2750+
},
2751+
"patterns": [
2752+
{
2753+
"include": "#support_functions"
2754+
},
2755+
{
2756+
"include": "#type-declarations"
2757+
},
2758+
{
2759+
"include": "#variable_assignment"
2760+
},
2761+
{
2762+
"match": "\\w+",
2763+
"name": "variable.other.go"
2764+
}
2765+
]
2766+
},
2767+
{
2768+
"include": "$self"
2769+
}
2770+
]
2771+
}
2772+
]
2773+
},
26522774
"var_assignment": {
26532775
"comment": "variable assignment with var keyword",
26542776
"patterns": [
@@ -2959,32 +3081,6 @@
29593081
}
29603082
}
29613083
},
2962-
"switch_select_case_variables": {
2963-
"comment": "variables after case control keyword in switch/select expression, to not scope them as property variables",
2964-
"match": "(?:(?:^\\s*(\\bcase\\b))(?:\\s+)([\\s\\S]+(?:\\:)\\s*(?:/(?:/|\\*).*)?)$)",
2965-
"captures": {
2966-
"1": {
2967-
"name": "keyword.control.go"
2968-
},
2969-
"2": {
2970-
"patterns": [
2971-
{
2972-
"include": "#type-declarations"
2973-
},
2974-
{
2975-
"include": "#support_functions"
2976-
},
2977-
{
2978-
"include": "#variable_assignment"
2979-
},
2980-
{
2981-
"match": "\\w+",
2982-
"name": "variable.other.go"
2983-
}
2984-
]
2985-
}
2986-
}
2987-
},
29883084
"slice_index_variables": {
29893085
"comment": "slice index and capacity variables, to not scope them as property variables",
29903086
"match": "(?<=\\w\\[)((?:(?:\\b[\\w\\.\\*\\+/\\-\\%\\<\\>\\|\\&]+\\:)|(?:\\:\\b[\\w\\.\\*\\+/\\-\\%\\<\\>\\|\\&]+))(?:\\b[\\w\\.\\*\\+/\\-\\%\\<\\>\\|\\&]+)?(?:\\:\\b[\\w\\.\\*\\+/\\-\\%\\<\\>\\|\\&]+)?)(?=\\])",
@@ -3077,40 +3173,65 @@
30773173
}
30783174
}
30793175
},
3080-
"field_hover": {
3081-
"comment": "struct field property and types when hovering with the mouse",
3082-
"match": "(?:(?<=^\\bfield\\b)\\s+([\\w\\*\\.]+)\\s+([\\s\\S]+))",
3083-
"captures": {
3084-
"1": {
3085-
"patterns": [
3086-
{
3087-
"include": "#type-declarations"
3176+
"hover": {
3177+
"comment": "hovering with the mouse",
3178+
"patterns": [
3179+
{
3180+
"comment": "struct field property and types when hovering with the mouse",
3181+
"match": "(?:(?<=^\\bfield\\b)\\s+([\\w\\*\\.]+)\\s+([\\s\\S]+))",
3182+
"captures": {
3183+
"1": {
3184+
"patterns": [
3185+
{
3186+
"include": "#type-declarations"
3187+
},
3188+
{
3189+
"match": "\\w+",
3190+
"name": "variable.other.property.go"
3191+
}
3192+
]
30883193
},
3089-
{
3090-
"match": "\\w+",
3091-
"name": "variable.other.property.go"
3194+
"2": {
3195+
"patterns": [
3196+
{
3197+
"match": "\\binvalid\\b\\s+\\btype\\b",
3198+
"name": "invalid.field.go"
3199+
},
3200+
{
3201+
"include": "#type-declarations-without-brackets"
3202+
},
3203+
{
3204+
"include": "#parameter-variable-types"
3205+
},
3206+
{
3207+
"match": "\\w+",
3208+
"name": "entity.name.type.go"
3209+
}
3210+
]
30923211
}
3093-
]
3212+
}
30943213
},
3095-
"2": {
3096-
"patterns": [
3097-
{
3098-
"match": "\\binvalid\\b\\s+\\btype\\b",
3099-
"name": "invalid.field.go"
3100-
},
3101-
{
3102-
"include": "#type-declarations-without-brackets"
3103-
},
3104-
{
3105-
"include": "#parameter-variable-types"
3106-
},
3107-
{
3108-
"match": "\\w+",
3109-
"name": "entity.name.type.go"
3214+
{
3215+
"comment": "return types when hovering with the mouse",
3216+
"match": "(?:(?<=^\\breturns\\b)\\s+([\\s\\S]+))",
3217+
"captures": {
3218+
"1": {
3219+
"patterns": [
3220+
{
3221+
"include": "#type-declarations-without-brackets"
3222+
},
3223+
{
3224+
"include": "#parameter-variable-types"
3225+
},
3226+
{
3227+
"match": "\\w+",
3228+
"name": "entity.name.type.go"
3229+
}
3230+
]
31103231
}
3111-
]
3232+
}
31123233
}
3113-
}
3234+
]
31143235
},
31153236
"other_variables": {
31163237
"comment": "all other variables",

0 commit comments

Comments
 (0)