|
| 1 | +{ |
| 2 | + "//": [ |
| 3 | + "See https://protobuf.com/docs/language-spec", |
| 4 | + "Comments in this file are stored in // keys." |
| 5 | + ], |
| 6 | + "scopeName": "source.proto-decl", |
| 7 | + "patterns": [ |
| 8 | + { |
| 9 | + "name": "comment.line.double-slash.proto-decl", |
| 10 | + "begin": "//", |
| 11 | + "end": "$\\N?" |
| 12 | + }, |
| 13 | + { |
| 14 | + "name": "comment.line.block.proto-decl", |
| 15 | + "begin": "/\\*", |
| 16 | + "end": "\\*/" |
| 17 | + }, |
| 18 | + { |
| 19 | + "name": "string.quoted.double.proto-decl", |
| 20 | + "begin": "\"", |
| 21 | + "end": "(?<!\\\\)(\\\\\\\\)*\"|$", |
| 22 | + "patterns": [ |
| 23 | + { |
| 24 | + "include": "#escapes" |
| 25 | + }, |
| 26 | + { |
| 27 | + "include": "#bad_escapes" |
| 28 | + } |
| 29 | + ], |
| 30 | + "captures": { |
| 31 | + "1": { |
| 32 | + "name": "constant.character.escape.proto-decl" |
| 33 | + } |
| 34 | + } |
| 35 | + }, |
| 36 | + { |
| 37 | + "name": "string.quoted.single.proto-decl", |
| 38 | + "begin": "'", |
| 39 | + "end": "(?<!\\\\)(\\\\\\\\)*'|$", |
| 40 | + "patterns": [ |
| 41 | + { |
| 42 | + "include": "#escapes" |
| 43 | + }, |
| 44 | + |
| 45 | + { |
| 46 | + "include": "#bad_escapes" |
| 47 | + } |
| 48 | + ], |
| 49 | + "captures": { |
| 50 | + "1": { |
| 51 | + "name": "constant.character.escape.proto-decl" |
| 52 | + } |
| 53 | + } |
| 54 | + }, |
| 55 | + { |
| 56 | + "//": "Declarations that name a type", |
| 57 | + "match": "(builtin|message|group|enum|service) ((?:[^\\s]+\\.)*[^\\s]+)$", |
| 58 | + "captures": { |
| 59 | + "1": { |
| 60 | + "name": "keyword.control.proto-decl" |
| 61 | + }, |
| 62 | + "2": { |
| 63 | + "name": "entity.name.type.proto-decl" |
| 64 | + } |
| 65 | + } |
| 66 | + }, |
| 67 | + |
| 68 | + { |
| 69 | + "//": "Declarations that name a variable", |
| 70 | + "match": "(field|extension|oneof|const) ((?:[^\\s]+\\.)(?:[^\\s]+))\\.([^\\s]+)$", |
| 71 | + "captures": { |
| 72 | + "1": { |
| 73 | + "name": "keyword.control.proto-decl" |
| 74 | + }, |
| 75 | + "2": { |
| 76 | + "name": "entity.name.type.proto-decl" |
| 77 | + }, |
| 78 | + "3": { |
| 79 | + "name": "variable.other.proto-decl" |
| 80 | + } |
| 81 | + } |
| 82 | + }, |
| 83 | + |
| 84 | + { |
| 85 | + "//": "Declarations that name a variable", |
| 86 | + "match": "(rpc) ((?:[^\\s]+\\.)(?:[^\\s]+))\\.([^\\s]+)$", |
| 87 | + "captures": { |
| 88 | + "1": { |
| 89 | + "name": "keyword.control.proto-decl" |
| 90 | + }, |
| 91 | + "2": { |
| 92 | + "name": "entity.name.type.proto-decl" |
| 93 | + }, |
| 94 | + "3": { |
| 95 | + "name": "entity.name.function.proto-decl" |
| 96 | + } |
| 97 | + } |
| 98 | + }, |
| 99 | + { |
| 100 | + "name": "constant.numeric.proto-decl", |
| 101 | + "match": "(\\.|\\b)[0-9](\\.|([eE][-+]?)|\\w)*" |
| 102 | + }, |
| 103 | + { |
| 104 | + "//": "Declarations that name a function", |
| 105 | + "match": "(rpc) ((:?[^\\s]+\\.)+)([^\\s]+)", |
| 106 | + "captures": { |
| 107 | + "1": { |
| 108 | + "name": "keyword.control.proto-decl" |
| 109 | + }, |
| 110 | + "2": { |
| 111 | + "name": "entity.name.type.proto-decl" |
| 112 | + }, |
| 113 | + "3": { |
| 114 | + "name": "entity.name.function.proto-decl" |
| 115 | + } |
| 116 | + } |
| 117 | + }, |
| 118 | + { |
| 119 | + "name": "keyword.other.proto-decl", |
| 120 | + "match": "\\b(weak|public|group|map|extensions|reserved|stream|returns|to|optional|required|repeated)\\b" |
| 121 | + }, |
| 122 | + { |
| 123 | + "name": "constant.language.proto-decl", |
| 124 | + "match": "\\b(inf|nan|true|false|max)\\b" |
| 125 | + }, |
| 126 | + { |
| 127 | + "//": [ |
| 128 | + "This picks up any loose identifiers/numbers that aren't otherwise highlighted.", |
| 129 | + "The pattern is VERY generous: it matches all kinds of Unicode characters." |
| 130 | + ], |
| 131 | + "name": "variable.other.proto-decl", |
| 132 | + "match": "\\b\\w+\\b" |
| 133 | + } |
| 134 | + ], |
| 135 | + "repository": { |
| 136 | + "escapes": { |
| 137 | + "name": "constant.character.escape.proto-decl", |
| 138 | + "//": [ |
| 139 | + "This pattern will match all possible escape sequences, so they can be highlighted as such.", |
| 140 | + "They are as follows, without regex escaping applied:", |
| 141 | + "simple_escape_seq: \\[abfnrtv\\'\"?]", |
| 142 | + "hex_escape_seq: \\[xX][a-fA-F0-9]{1,2}", |
| 143 | + "octal_escape_seq: \\[0-7]{1,3}", |
| 144 | + "unicode_escape_seq: \\u[a-fA-F0-9]{4}", |
| 145 | + "unicode_escape_seq: \\U[a-fA-F0-9]{8}" |
| 146 | + ], |
| 147 | + "match": "(\\\\[abfnrtv\\\\'\"\\?])|(\\\\[xX][a-fA-F0-9]{1,2})|(\\\\[0-7]{1,3})|(\\\\u[a-fA-F0-9]{4})|(\\\\U[a-fA-F0-9]{8})" |
| 148 | + }, |
| 149 | + "bad_escapes": { |
| 150 | + "name": "invalid.error", |
| 151 | + "//": "This pattern picks up all invalid variants of the above. For example, this will highlight \\xxx, not just the \\x.", |
| 152 | + "match": "(\\\\[xX][^'\"\\\\]{1,2})|(\\\\u[^'\"\\\\]{1,4})|(\\\\U[^'\"\\\\]{0,8})|(\\\\.)" |
| 153 | + } |
| 154 | + } |
| 155 | +} |
0 commit comments