|
4 | 4 | "If you want to provide a fix or improvement, please create a pull request against the original repository.",
|
5 | 5 | "Once accepted there, we are happy to receive an update request."
|
6 | 6 | ],
|
7 |
| - "version": "https://github.com/worlpaker/go-syntax/commit/0ce19cdf1cb5dab6aa99ccc933be9bd21e855ed1", |
| 7 | + "version": "https://github.com/worlpaker/go-syntax/commit/8c70c078f56d237f72574ce49cc95839c4f8a741", |
8 | 8 | "name": "Go",
|
9 | 9 | "scopeName": "source.go",
|
10 | 10 | "patterns": [
|
|
34 | 34 | "include": "#group-variables"
|
35 | 35 | },
|
36 | 36 | {
|
37 |
| - "include": "#field_hover" |
| 37 | + "include": "#hover" |
38 | 38 | }
|
39 | 39 | ]
|
40 | 40 | },
|
|
115 | 115 | "include": "#property_variables"
|
116 | 116 | },
|
117 | 117 | {
|
118 |
| - "include": "#switch_select_case_variables" |
| 118 | + "include": "#switch_variables" |
119 | 119 | },
|
120 | 120 | {
|
121 | 121 | "include": "#other_variables"
|
|
1704 | 1704 | },
|
1705 | 1705 | "support_functions": {
|
1706 | 1706 | "comment": "Support Functions",
|
1707 |
| - "match": "(?:(?:((?<=\\.)\\b\\w+)|(\\b\\w+))(\\[(?:(?:[\\w\\.\\*\\[\\]\\{\\}\"\\']+)(?:(?:\\,\\s*(?:[\\w\\.\\*\\[\\]\\{\\}]+))*))?\\])?(?=\\())", |
| 1707 | + "match": "(?:(?:((?<=\\.)\\b\\w+)|(\\b\\w+))(?<brackets>\\[(?:[^\\[\\]]|\\g<brackets>)*\\])?(?=\\())", |
1708 | 1708 | "captures": {
|
1709 | 1709 | "1": {
|
1710 | 1710 | "name": "entity.name.function.support.go"
|
|
1761 | 1761 | "include": "#after_control_variables"
|
1762 | 1762 | },
|
1763 | 1763 | {
|
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>)*\\])?(?=\\{)", |
1765 | 1766 | "captures": {
|
1766 | 1767 | "1": {
|
1767 | 1768 | "patterns": [
|
|
1807 | 1808 | },
|
1808 | 1809 | "type_assertion_inline": {
|
1809 | 1810 | "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\\.\\*\\[\\]\\{\\}]+))*))?\\])?))(?=\\)))", |
1811 | 1812 | "captures": {
|
1812 | 1813 | "1": {
|
1813 | 1814 | "name": "keyword.type.go"
|
1814 | 1815 | },
|
1815 | 1816 | "2": {
|
1816 | 1817 | "patterns": [
|
1817 | 1818 | {
|
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" |
1819 | 1844 | },
|
1820 | 1845 | {
|
1821 | 1846 | "match": "\\w+",
|
|
1904 | 1929 | },
|
1905 | 1930 | {
|
1906 | 1931 | "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*(?=\\}))", |
1908 | 1933 | "captures": {
|
1909 | 1934 | "1": {
|
1910 | 1935 | "patterns": [
|
1911 | 1936 | {
|
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/]+)(?:\\;)?))", |
1913 | 1938 | "captures": {
|
1914 | 1939 | "1": {
|
1915 | 1940 | "patterns": [
|
|
1958 | 1983 | },
|
1959 | 1984 | {
|
1960 | 1985 | "comment": "property variables and types",
|
1961 |
| - "match": "(?:((?:(?:\\w+\\,\\s*)+)?(?:\\w+\\s+))([^\\`\"\\/]+))", |
| 1986 | + "match": "(\\b\\w+(?:\\s*\\,\\s*\\b\\w+)*)\\s*([^\\`\"\\/]+)", |
1962 | 1987 | "captures": {
|
1963 | 1988 | "1": {
|
1964 | 1989 | "patterns": [
|
|
1994 | 2019 | "patterns": [
|
1995 | 2020 | {
|
1996 | 2021 | "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*)(\\{))", |
1998 | 2023 | "beginCaptures": {
|
1999 | 2024 | "1": {
|
2000 | 2025 | "patterns": [
|
|
2031 | 2056 | },
|
2032 | 2057 | {
|
2033 | 2058 | "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*)(\\{))", |
2035 | 2060 | "beginCaptures": {
|
2036 | 2061 | "1": {
|
2037 | 2062 | "patterns": [
|
|
2068 | 2093 | },
|
2069 | 2094 | {
|
2070 | 2095 | "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*)(\\())", |
2072 | 2097 | "beginCaptures": {
|
2073 | 2098 | "1": {
|
2074 | 2099 | "patterns": [
|
|
2390 | 2415 | },
|
2391 | 2416 | "after_control_variables": {
|
2392 | 2417 | "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*)(?=\\{))", |
2394 | 2419 | "captures": {
|
2395 | 2420 | "1": {
|
2396 | 2421 | "patterns": [
|
|
2649 | 2674 | }
|
2650 | 2675 | ]
|
2651 | 2676 | },
|
| 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 | + }, |
2652 | 2774 | "var_assignment": {
|
2653 | 2775 | "comment": "variable assignment with var keyword",
|
2654 | 2776 | "patterns": [
|
|
2959 | 3081 | }
|
2960 | 3082 | }
|
2961 | 3083 | },
|
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 |
| - }, |
2988 | 3084 | "slice_index_variables": {
|
2989 | 3085 | "comment": "slice index and capacity variables, to not scope them as property variables",
|
2990 | 3086 | "match": "(?<=\\w\\[)((?:(?:\\b[\\w\\.\\*\\+/\\-\\%\\<\\>\\|\\&]+\\:)|(?:\\:\\b[\\w\\.\\*\\+/\\-\\%\\<\\>\\|\\&]+))(?:\\b[\\w\\.\\*\\+/\\-\\%\\<\\>\\|\\&]+)?(?:\\:\\b[\\w\\.\\*\\+/\\-\\%\\<\\>\\|\\&]+)?)(?=\\])",
|
|
3077 | 3173 | }
|
3078 | 3174 | }
|
3079 | 3175 | },
|
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 | + ] |
3088 | 3193 | },
|
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 | + ] |
3092 | 3211 | }
|
3093 |
| - ] |
| 3212 | + } |
3094 | 3213 | },
|
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 | + ] |
3110 | 3231 | }
|
3111 |
| - ] |
| 3232 | + } |
3112 | 3233 | }
|
3113 |
| - } |
| 3234 | + ] |
3114 | 3235 | },
|
3115 | 3236 | "other_variables": {
|
3116 | 3237 | "comment": "all other variables",
|
|
0 commit comments