diff options
Diffstat (limited to 'editors/code')
-rw-r--r-- | editors/code/package.json | 9 | ||||
-rw-r--r-- | editors/code/rust.tmGrammar.json | 1725 | ||||
-rw-r--r-- | editors/code/src/commands.ts | 25 | ||||
-rw-r--r-- | editors/code/src/lsp_ext.ts | 2 | ||||
-rw-r--r-- | editors/code/src/main.ts | 1 |
5 files changed, 1076 insertions, 686 deletions
diff --git a/editors/code/package.json b/editors/code/package.json index 6a712a8a8..4bd3117fc 100644 --- a/editors/code/package.json +++ b/editors/code/package.json | |||
@@ -182,6 +182,11 @@ | |||
182 | "command": "rust-analyzer.toggleInlayHints", | 182 | "command": "rust-analyzer.toggleInlayHints", |
183 | "title": "Toggle inlay hints", | 183 | "title": "Toggle inlay hints", |
184 | "category": "Rust Analyzer" | 184 | "category": "Rust Analyzer" |
185 | }, | ||
186 | { | ||
187 | "command": "rust-analyzer.openDocs", | ||
188 | "title": "Open docs under cursor", | ||
189 | "category": "Rust Analyzer" | ||
185 | } | 190 | } |
186 | ], | 191 | ], |
187 | "keybindings": [ | 192 | "keybindings": [ |
@@ -1044,6 +1049,10 @@ | |||
1044 | { | 1049 | { |
1045 | "command": "rust-analyzer.toggleInlayHints", | 1050 | "command": "rust-analyzer.toggleInlayHints", |
1046 | "when": "inRustProject" | 1051 | "when": "inRustProject" |
1052 | }, | ||
1053 | { | ||
1054 | "command": "rust-analyzer.openDocs", | ||
1055 | "when": "inRustProject" | ||
1047 | } | 1056 | } |
1048 | ] | 1057 | ] |
1049 | } | 1058 | } |
diff --git a/editors/code/rust.tmGrammar.json b/editors/code/rust.tmGrammar.json index 0be2583db..3ddd14f9c 100644 --- a/editors/code/rust.tmGrammar.json +++ b/editors/code/rust.tmGrammar.json | |||
@@ -1,686 +1,1043 @@ | |||
1 | { | 1 | { |
2 | "name": "Rust", | 2 | "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", |
3 | "scopeName": "source.rust", | 3 | "name": "Rust", |
4 | "patterns": [ | 4 | "fileTypes": [ |
5 | { | 5 | "rs" |
6 | "comment": "Implementation", | 6 | ], |
7 | "begin": "\\b(impl)\\b", | 7 | "scopeName": "source.rust", |
8 | "end": "\\{", | 8 | "patterns": [ |
9 | "beginCaptures": { | 9 | { |
10 | "1": { | 10 | "comment": "boxed slice literal", |
11 | "name": "storage.type.rust" | 11 | "begin": "(<)(\\[)", |
12 | } | 12 | "beginCaptures": { |
13 | }, | 13 | "1": { |
14 | "patterns": [ | 14 | "name": "punctuation.brackets.angle.rust" |
15 | { | 15 | }, |
16 | "include": "#block_comment" | 16 | "2": { |
17 | }, | 17 | "name": "punctuation.brackets.square.rust" |
18 | { | 18 | } |
19 | "include": "#line_comment" | 19 | }, |
20 | }, | 20 | "end": ">", |
21 | { | 21 | "endCaptures": { |
22 | "include": "#sigils" | 22 | "0": { |
23 | }, | 23 | "name": "punctuation.brackets.angle.rust" |
24 | { | 24 | } |
25 | "include": "#mut" | 25 | }, |
26 | }, | 26 | "patterns": [ |
27 | { | 27 | { |
28 | "include": "#dyn" | 28 | "include": "#comments" |
29 | }, | 29 | }, |
30 | { | 30 | { |
31 | "include": "#ref_lifetime" | 31 | "include": "#gtypes" |
32 | }, | 32 | }, |
33 | { | 33 | { |
34 | "include": "#core_types" | 34 | "include": "#lvariables" |
35 | }, | 35 | }, |
36 | { | 36 | { |
37 | "include": "#core_marker" | 37 | "include": "#lifetimes" |
38 | }, | 38 | }, |
39 | { | 39 | { |
40 | "include": "#core_traits" | 40 | "include": "#punctuation" |
41 | }, | 41 | }, |
42 | { | 42 | { |
43 | "include": "#std_types" | 43 | "include": "#types" |
44 | }, | 44 | } |
45 | { | 45 | ] |
46 | "include": "#std_traits" | 46 | }, |
47 | }, | 47 | { |
48 | { | 48 | "comment": "macro type metavariables", |
49 | "include": "#type_params" | 49 | "name": "meta.macro.metavariable.type.rust", |
50 | }, | 50 | "match": "(\\$)((crate)|([A-Z][A-Za-z0-9_]*))((:)(block|expr|ident|item|lifetime|literal|meta|pat|path|stmt|tt|ty|vis))?", |
51 | { | 51 | "captures": { |
52 | "include": "#where" | 52 | "1": { |
53 | }, | 53 | "name": "keyword.operator.macro.dollar.rust" |
54 | { | 54 | }, |
55 | "name": "storage.type.rust", | 55 | "3": { |
56 | "match": "\\bfor\\b" | 56 | "name": "keyword.other.crate.rust" |
57 | }, | 57 | }, |
58 | { | 58 | "4": { |
59 | "include": "#type" | 59 | "name": "entity.name.type.metavariable.rust" |
60 | } | 60 | }, |
61 | ] | 61 | "6": { |
62 | }, | 62 | "name": "keyword.operator.key-value.rust" |
63 | { | 63 | }, |
64 | "include": "#block_doc_comment" | 64 | "7": { |
65 | }, | 65 | "name": "variable.other.metavariable.specifier.rust" |
66 | { | 66 | } |
67 | "include": "#block_comment" | 67 | }, |
68 | }, | 68 | "patterns": [ |
69 | { | 69 | { |
70 | "include": "#line_doc_comment" | 70 | "include": "#keywords" |
71 | }, | 71 | } |
72 | { | 72 | ] |
73 | "include": "#line_comment" | 73 | }, |
74 | }, | 74 | { |
75 | { | 75 | "comment": "macro metavariables", |
76 | "comment": "Attribute", | 76 | "name": "meta.macro.metavariable.rust", |
77 | "name": "meta.attribute.rust", | 77 | "match": "(\\$)([a-z][A-Za-z0-9_]*)((:)(block|expr|ident|item|lifetime|literal|meta|pat|path|stmt|tt|ty|vis))?", |
78 | "begin": "#\\!?\\[(\\w*)", | 78 | "captures": { |
79 | "end": "\\]", | 79 | "1": { |
80 | "captures": { | 80 | "name": "keyword.operator.macro.dollar.rust" |
81 | "1": { | 81 | }, |
82 | "name": "entity.name.function.attribute.rust" | 82 | "2": { |
83 | } | 83 | "name": "variable.other.metavariable.name.rust" |
84 | }, | 84 | }, |
85 | "patterns": [ | 85 | "4": { |
86 | { | 86 | "name": "keyword.operator.key-value.rust" |
87 | "include": "#string_literal" | 87 | }, |
88 | }, | 88 | "5": { |
89 | { | 89 | "name": "variable.other.metavariable.specifier.rust" |
90 | "include": "#block_doc_comment" | 90 | } |
91 | }, | 91 | }, |
92 | { | 92 | "patterns": [ |
93 | "include": "#block_comment" | 93 | { |
94 | }, | 94 | "include": "#keywords" |
95 | { | 95 | } |
96 | "include": "#line_doc_comment" | 96 | ] |
97 | }, | 97 | }, |
98 | { | 98 | { |
99 | "include": "#line_comment" | 99 | "comment": "macro rules", |
100 | } | 100 | "name": "meta.macro.rules.rust", |
101 | ] | 101 | "match": "\\b(macro_rules!)\\s+(([a-z0-9_]+)|([A-Z][a-z0-9_]*))\\s+(\\{)", |
102 | }, | 102 | "captures": { |
103 | { | 103 | "1": { |
104 | "comment": "Single-quote string literal (character)", | 104 | "name": "entity.name.function.macro.rules.rust" |
105 | "name": "string.quoted.single.rust", | 105 | }, |
106 | "match": "b?'([^'\\\\]|\\\\(x[0-9A-Fa-f]{2}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.))'" | 106 | "3": { |
107 | }, | 107 | "name": "entity.name.function.macro.rust" |
108 | { | 108 | }, |
109 | "include": "#string_literal" | 109 | "4": { |
110 | }, | 110 | "name": "entity.name.type.macro.rust" |
111 | { | 111 | }, |
112 | "include": "#raw_string_literal" | 112 | "5": { |
113 | }, | 113 | "name": "punctuation.brackets.curly.rust" |
114 | { | 114 | } |
115 | "comment": "Floating point literal (fraction)", | 115 | } |
116 | "name": "constant.numeric.float.rust", | 116 | }, |
117 | "match": "\\b[0-9][0-9_]*\\.[0-9][0-9_]*([eE][+-]?[0-9_]+)?(f32|f64)?\\b" | 117 | { |
118 | }, | 118 | "comment": "attributes", |
119 | { | 119 | "name": "meta.attribute.rust", |
120 | "comment": "Floating point literal (exponent)", | 120 | "begin": "(#)(\\!?)(\\[)", |
121 | "name": "constant.numeric.float.rust", | 121 | "beginCaptures": { |
122 | "match": "\\b[0-9][0-9_]*(\\.[0-9][0-9_]*)?[eE][+-]?[0-9_]+(f32|f64)?\\b" | 122 | "1": { |
123 | }, | 123 | "name": "punctuation.definition.attribute.rust" |
124 | { | 124 | }, |
125 | "comment": "Floating point literal (typed)", | 125 | "2": { |
126 | "name": "constant.numeric.float.rust", | 126 | "name": "keyword.operator.attribute.inner.rust" |
127 | "match": "\\b[0-9][0-9_]*(\\.[0-9][0-9_]*)?([eE][+-]?[0-9_]+)?(f32|f64)\\b" | 127 | }, |
128 | }, | 128 | "3": { |
129 | { | 129 | "name": "punctuation.brackets.attribute.rust" |
130 | "comment": "Integer literal (decimal)", | 130 | } |
131 | "name": "constant.numeric.integer.decimal.rust", | 131 | }, |
132 | "match": "\\b[0-9][0-9_]*([ui](8|16|32|64|128|s|size))?\\b" | 132 | "end": "\\]", |
133 | }, | 133 | "endCaptures": { |
134 | { | 134 | "0": { |
135 | "comment": "Integer literal (hexadecimal)", | 135 | "name": "punctuation.brackets.attribute.rust" |
136 | "name": "constant.numeric.integer.hexadecimal.rust", | 136 | } |
137 | "match": "\\b0x[a-fA-F0-9_]+([ui](8|16|32|64|128|s|size))?\\b" | 137 | }, |
138 | }, | 138 | "patterns": [ |
139 | { | 139 | { |
140 | "comment": "Integer literal (octal)", | 140 | "include": "#keywords" |
141 | "name": "constant.numeric.integer.octal.rust", | 141 | }, |
142 | "match": "\\b0o[0-7_]+([ui](8|16|32|64|128|s|size))?\\b" | 142 | { |
143 | }, | 143 | "include": "#punctuation" |
144 | { | 144 | }, |
145 | "comment": "Integer literal (binary)", | 145 | { |
146 | "name": "constant.numeric.integer.binary.rust", | 146 | "include": "#strings" |
147 | "match": "\\b0b[01_]+([ui](8|16|32|64|128|s|size))?\\b" | 147 | }, |
148 | }, | 148 | { |
149 | { | 149 | "include": "#gtypes" |
150 | "comment": "Static storage modifier", | 150 | }, |
151 | "name": "storage.modifier.static.rust", | 151 | { |
152 | "match": "\\bstatic\\b" | 152 | "include": "#types" |
153 | }, | 153 | } |
154 | { | 154 | ] |
155 | "comment": "Boolean constant", | 155 | }, |
156 | "name": "constant.language.boolean.rust", | 156 | { |
157 | "match": "\\b(true|false)\\b" | 157 | "comment": "modules", |
158 | }, | 158 | "match": "(mod)\\s+([a-z][A-Za-z0-9_]*)", |
159 | { | 159 | "captures": { |
160 | "comment": "Control keyword", | 160 | "1": { |
161 | "name": "keyword.control.rust", | 161 | "name": "keyword.control.rust" |
162 | "match": "\\b(async|await|break|continue|else|if|in|for|loop|match|return|try|while)\\b" | 162 | }, |
163 | }, | 163 | "2": { |
164 | { | 164 | "name": "entity.name.module.rust" |
165 | "comment": "Keyword", | 165 | } |
166 | "name": "keyword.other.rust", | 166 | } |
167 | "match": "\\b(crate|extern|mod|let|ref|use|super|move|as)\\b" | 167 | }, |
168 | }, | 168 | { |
169 | { | 169 | "comment": "external crate imports", |
170 | "comment": "Reserved keyword", | 170 | "name": "meta.import.rust", |
171 | "name": "invalid.deprecated.rust", | 171 | "begin": "\\b(extern)\\s+(crate)", |
172 | "match": "\\b(abstract|alignof|become|do|final|macro|offsetof|override|priv|proc|pure|sizeof|typeof|virtual|yield)\\b" | 172 | "beginCaptures": { |
173 | }, | 173 | "1": { |
174 | { | 174 | "name": "keyword.control.rust" |
175 | "include": "#unsafe" | 175 | }, |
176 | }, | 176 | "2": { |
177 | { | 177 | "name": "keyword.other.crate.rust" |
178 | "include": "#sigils" | 178 | } |
179 | }, | 179 | }, |
180 | { | 180 | "end": ";", |
181 | "include": "#self" | 181 | "endCaptures": { |
182 | }, | 182 | "0": { |
183 | { | 183 | "name": "punctuation.semi.rust" |
184 | "include": "#mut" | 184 | } |
185 | }, | 185 | }, |
186 | { | 186 | "patterns": [ |
187 | "include": "#dyn" | 187 | { |
188 | }, | 188 | "include": "#comments" |
189 | { | 189 | }, |
190 | "include": "#impl" | 190 | { |
191 | }, | 191 | "include": "#keywords" |
192 | { | 192 | }, |
193 | "include": "#box" | 193 | { |
194 | }, | 194 | "include": "#punctuation" |
195 | { | 195 | } |
196 | "include": "#lifetime" | 196 | ] |
197 | }, | 197 | }, |
198 | { | 198 | { |
199 | "include": "#ref_lifetime" | 199 | "comment": "use statements", |
200 | }, | 200 | "name": "meta.use.rust", |
201 | { | 201 | "begin": "\\b(use)\\s", |
202 | "include": "#const" | 202 | "beginCaptures": { |
203 | }, | 203 | "1": { |
204 | { | 204 | "name": "keyword.control.rust" |
205 | "include": "#pub" | 205 | } |
206 | }, | 206 | }, |
207 | { | 207 | "end": ";", |
208 | "comment": "Miscellaneous operator", | 208 | "endCaptures": { |
209 | "name": "keyword.operator.misc.rust", | 209 | "0": { |
210 | "match": "(=>|::|\\?)" | 210 | "name": "punctuation.semi.rust" |
211 | }, | 211 | } |
212 | { | 212 | }, |
213 | "comment": "Comparison operator", | 213 | "patterns": [ |
214 | "name": "keyword.operator.comparison.rust", | 214 | { |
215 | "match": "(&&|\\|\\||==|!=)" | 215 | "include": "#comments" |
216 | }, | 216 | }, |
217 | { | 217 | { |
218 | "comment": "Assignment operator", | 218 | "include": "#keywords" |
219 | "name": "keyword.operator.assignment.rust", | 219 | }, |
220 | "match": "(\\+=|-=|/=|\\*=|%=|\\^=|&=|\\|=|<<=|>>=|=)" | 220 | { |
221 | }, | 221 | "include": "#namespaces" |
222 | { | 222 | }, |
223 | "comment": "Arithmetic operator", | 223 | { |
224 | "name": "keyword.operator.arithmetic.rust", | 224 | "include": "#punctuation" |
225 | "match": "(!|\\+|-|/|\\*|%|\\^|&|\\||<<|>>)" | 225 | }, |
226 | }, | 226 | { |
227 | { | 227 | "include": "#types" |
228 | "comment": "Comparison operator (second group because of regex precedence)", | 228 | }, |
229 | "name": "keyword.operator.comparison.rust", | 229 | { |
230 | "match": "(<=|>=|<|>)" | 230 | "include": "#lvariables" |
231 | }, | 231 | } |
232 | { | 232 | ] |
233 | "include": "#core_types" | 233 | }, |
234 | }, | 234 | { |
235 | { | 235 | "include": "#comments" |
236 | "include": "#core_vars" | 236 | }, |
237 | }, | 237 | { |
238 | { | 238 | "include": "#lvariables" |
239 | "include": "#core_marker" | 239 | }, |
240 | }, | 240 | { |
241 | { | 241 | "include": "#constants" |
242 | "include": "#core_traits" | 242 | }, |
243 | }, | 243 | { |
244 | { | 244 | "include": "#gtypes" |
245 | "include": "#std_types" | 245 | }, |
246 | }, | 246 | { |
247 | { | 247 | "include": "#functions" |
248 | "include": "#std_traits" | 248 | }, |
249 | }, | 249 | { |
250 | { | 250 | "include": "#types" |
251 | "comment": "Built-in macro", | 251 | }, |
252 | "name": "support.function.builtin.rust", | 252 | { |
253 | "match": "\\b(macro_rules|compile_error|format_args|env|option_env|concat_idents|concat|line|column|file|stringify|include|include_str|include_bytes|module_path|cfg)!" | 253 | "include": "#keywords" |
254 | }, | 254 | }, |
255 | { | 255 | { |
256 | "comment": "Core macro", | 256 | "include": "#lifetimes" |
257 | "name": "support.function.core.rust", | 257 | }, |
258 | "match": "\\b(panic|assert|assert_eq|assert_ne|debug_assert|debug_assert_eq|debug_assert_ne|try|write|writeln|unreachable|unimplemented)!" | 258 | { |
259 | }, | 259 | "include": "#macros" |
260 | { | 260 | }, |
261 | "comment": "Standard library macro", | 261 | { |
262 | "name": "support.function.std.rust", | 262 | "include": "#namespaces" |
263 | "match": "\\b(format|print|println|eprint|eprintln|select|vec)!" | 263 | }, |
264 | }, | 264 | { |
265 | { | 265 | "include": "#punctuation" |
266 | "comment": "Logging macro", | 266 | }, |
267 | "name": "support.function.log.rust", | 267 | { |
268 | "match": "\\b(log|error|warn|info|debug|trace|log_enabled)!" | 268 | "include": "#strings" |
269 | }, | 269 | }, |
270 | { | 270 | { |
271 | "comment": "Invocation of a macro", | 271 | "include": "#variables" |
272 | "match": "\\b([a-zA-Z_][a-zA-Z0-9_]*\\!)\\s*[({\\[]", | 272 | } |
273 | "captures": { | 273 | ], |
274 | "1": { | 274 | "repository": { |
275 | "name": "entity.name.function.macro.rust" | 275 | "comments": { |
276 | } | 276 | "patterns": [ |
277 | } | 277 | { |
278 | }, | 278 | "comment": "documentation comments", |
279 | { | 279 | "name": "comment.line.documentation.rust", |
280 | "comment": "Function call", | 280 | "match": "^\\s*///.*", |
281 | "match": "\\b([A-Za-z][A-Za-z0-9_]*|_[A-Za-z0-9_]+)\\s*\\(", | 281 | "patterns": [ |
282 | "captures": { | 282 | { |
283 | "1": { | 283 | "include": "#comments" |
284 | "name": "entity.name.function.rust" | 284 | } |
285 | } | 285 | ] |
286 | } | 286 | }, |
287 | }, | 287 | { |
288 | { | 288 | "comment": "line comments", |
289 | "comment": "Function call with type parameters", | 289 | "name": "comment.line.double-slash.rust", |
290 | "begin": "\\b([A-Za-z][A-Za-z0-9_]*|_[A-Za-z0-9_]+)\\s*(::)(?=\\s*<.*>\\s*\\()", | 290 | "match": "\\s*//.*", |
291 | "end": "\\(", | 291 | "patterns": [ |
292 | "captures": { | 292 | { |
293 | "1": { | 293 | "include": "#comments" |
294 | "name": "entity.name.function.rust" | 294 | } |
295 | }, | 295 | ] |
296 | "2": { | 296 | }, |
297 | "name": "keyword.operator.misc.rust" | 297 | { |
298 | } | 298 | "comment": "block comments", |
299 | }, | 299 | "name": "comment.block.rust", |
300 | "patterns": [ | 300 | "begin": "/\\*(?!\\*)", |
301 | { | 301 | "end": "\\*/", |
302 | "include": "#type_params" | 302 | "patterns": [ |
303 | } | 303 | { |
304 | ] | 304 | "include": "#comments" |
305 | }, | 305 | } |
306 | { | 306 | ] |
307 | "comment": "Function definition", | 307 | }, |
308 | "begin": "\\b(fn)\\s+([A-Za-z][A-Za-z0-9_]*|_[A-Za-z0-9_]+)", | 308 | { |
309 | "end": "[\\{;]", | 309 | "comment": "block documentation comments", |
310 | "beginCaptures": { | 310 | "name": "comment.block.documentation.rust", |
311 | "1": { | 311 | "begin": "/\\*\\*", |
312 | "name": "keyword.other.fn.rust" | 312 | "end": "\\*/", |
313 | }, | 313 | "patterns": [ |
314 | "2": { | 314 | { |
315 | "name": "entity.name.function.rust" | 315 | "include": "#comments" |
316 | } | 316 | } |
317 | }, | 317 | ] |
318 | "patterns": [ | 318 | }, |
319 | { | 319 | { |
320 | "include": "#block_comment" | 320 | "comment": "inferred types, wildcard patterns, ignored params", |
321 | }, | 321 | "name": "comment.char.underscore.rust", |
322 | { | 322 | "match": "\\b_\\w*\\b" |
323 | "include": "#line_comment" | 323 | } |
324 | }, | 324 | ] |
325 | { | 325 | }, |
326 | "include": "#sigils" | 326 | "constants": { |
327 | }, | 327 | "patterns": [ |
328 | { | 328 | { |
329 | "include": "#self" | 329 | "comment": "ALL CAPS constants", |
330 | }, | 330 | "name": "constant.other.caps.rust", |
331 | { | 331 | "match": "\\b[A-Z]{2}[A-Z0-9_]*\\b" |
332 | "include": "#mut" | 332 | }, |
333 | }, | 333 | { |
334 | { | 334 | "comment": "constant declarations", |
335 | "include": "#dyn" | 335 | "match": "\\b(const)\\s+([A-Z][A-Za-z0-9_]*)\\b", |
336 | }, | 336 | "captures": { |
337 | { | 337 | "1": { |
338 | "include": "#impl" | 338 | "name": "keyword.control.rust" |
339 | }, | 339 | }, |
340 | { | 340 | "2": { |
341 | "include": "#ref_lifetime" | 341 | "name": "constant.other.caps.rust" |
342 | }, | 342 | } |
343 | { | 343 | } |
344 | "include": "#core_types" | 344 | }, |
345 | }, | 345 | { |
346 | { | 346 | "comment": "decimal integers and floats", |
347 | "include": "#core_marker" | 347 | "name": "constant.numeric.decimal.rust", |
348 | }, | 348 | "match": "\\b\\d[\\d_]*(\\.?)[\\d_]*(?:(E)([+-])([\\d_]+))?(f32|f64|i128|i16|i32|i64|i8|isize|u128|u16|u32|u64|u8|usize)?\\b", |
349 | { | 349 | "captures": { |
350 | "include": "#core_traits" | 350 | "1": { |
351 | }, | 351 | "name": "punctuation.separator.dot.decimal.rust" |
352 | { | 352 | }, |
353 | "include": "#std_types" | 353 | "2": { |
354 | }, | 354 | "name": "keyword.operator.exponent.rust" |
355 | { | 355 | }, |
356 | "include": "#std_traits" | 356 | "3": { |
357 | }, | 357 | "name": "keyword.operator.exponent.sign.rust" |
358 | { | 358 | }, |
359 | "include": "#type_params" | 359 | "4": { |
360 | }, | 360 | "name": "constant.numeric.decimal.exponent.mantissa.rust" |
361 | { | 361 | }, |
362 | "include": "#const" | 362 | "5": { |
363 | }, | 363 | "name": "entity.name.type.numeric.rust" |
364 | { | 364 | } |
365 | "include": "#where" | 365 | } |
366 | }, | 366 | }, |
367 | { | 367 | { |
368 | "include": "#unsafe" | 368 | "comment": "hexadecimal integers", |
369 | }, | 369 | "name": "constant.numeric.hex.rust", |
370 | { | 370 | "match": "\\b0x[\\da-fA-F_]+(i128|i16|i32|i64|i8|isize|u128|u16|u32|u64|u8|usize)?\\b", |
371 | "comment": "Function arguments", | 371 | "captures": { |
372 | "match": "\bfn\b", | 372 | "1": { |
373 | "name": "keyword.other.fn.rust" | 373 | "name": "entity.name.type.numeric.rust" |
374 | } | 374 | } |
375 | ] | 375 | } |
376 | }, | 376 | }, |
377 | { | 377 | { |
378 | "comment": "Type declaration", | 378 | "comment": "octal integers", |
379 | "begin": "\\b(enum|struct|trait|union)\\s+([a-zA-Z_][a-zA-Z0-9_]*)", | 379 | "name": "constant.numeric.oct.rust", |
380 | "end": "[\\{\\(;]", | 380 | "match": "\\b0o[0-7_]+(i128|i16|i32|i64|i8|isize|u128|u16|u32|u64|u8|usize)?\\b", |
381 | "beginCaptures": { | 381 | "captures": { |
382 | "1": { | 382 | "1": { |
383 | "name": "storage.type.rust" | 383 | "name": "entity.name.type.numeric.rust" |
384 | }, | 384 | } |
385 | "2": { | 385 | } |
386 | "name": "entity.name.type.rust" | 386 | }, |
387 | } | 387 | { |
388 | }, | 388 | "comment": "binary integers", |
389 | "patterns": [ | 389 | "name": "constant.numeric.bin.rust", |
390 | { | 390 | "match": "\\b0b[01_]+(i128|i16|i32|i64|i8|isize|u128|u16|u32|u64|u8|usize)?\\b", |
391 | "include": "#block_comment" | 391 | "captures": { |
392 | }, | 392 | "1": { |
393 | { | 393 | "name": "entity.name.type.numeric.rust" |
394 | "include": "#line_comment" | 394 | } |
395 | }, | 395 | } |
396 | { | 396 | }, |
397 | "include": "#core_traits" | 397 | { |
398 | }, | 398 | "comment": "booleans", |
399 | { | 399 | "name": "constant.language.bool.rust", |
400 | "include": "#std_traits" | 400 | "match": "\\btrue|false\\b" |
401 | }, | 401 | } |
402 | { | 402 | ] |
403 | "include": "#type_params" | 403 | }, |
404 | }, | 404 | "escapes": { |
405 | { | 405 | "comment": "escapes: ASCII, byte, Unicode, quote, regex", |
406 | "include": "#core_types" | 406 | "name": "constant.character.escape.rust", |
407 | }, | 407 | "match": "(\\\\)(?:(?:(x[0-7][0-7a-fA-F])|(u(\\{)[\\da-fA-F]{4,6}(\\}))|.))", |
408 | { | 408 | "captures": { |
409 | "include": "#pub" | 409 | "1": { |
410 | }, | 410 | "name": "constant.character.escape.backslash.rust" |
411 | { | 411 | }, |
412 | "include": "#where" | 412 | "2": { |
413 | } | 413 | "name": "constant.character.escape.bit.rust" |
414 | ] | 414 | }, |
415 | }, | 415 | "3": { |
416 | { | 416 | "name": "constant.character.escape.unicode.rust" |
417 | "comment": "Type alias", | 417 | }, |
418 | "begin": "\\b(type)\\s+([a-zA-Z_][a-zA-Z0-9_]*)", | 418 | "4": { |
419 | "end": ";", | 419 | "name": "constant.character.escape.unicode.punctuation.rust" |
420 | "beginCaptures": { | 420 | }, |
421 | "1": { | 421 | "5": { |
422 | "name": "storage.type.rust" | 422 | "name": "constant.character.escape.unicode.punctuation.rust" |
423 | }, | 423 | } |
424 | "2": { | 424 | } |
425 | "name": "entity.name.type.rust" | 425 | }, |
426 | } | 426 | "functions": { |
427 | }, | 427 | "patterns": [ |
428 | "patterns": [ | 428 | { |
429 | { | 429 | "comment": "function definition", |
430 | "include": "#block_comment" | 430 | "name": "meta.function.definition.rust", |
431 | }, | 431 | "begin": "\\b(fn)\\s+([A-Za-z0-9_]+)((\\()|(<))", |
432 | { | 432 | "beginCaptures": { |
433 | "include": "#line_comment" | 433 | "1": { |
434 | }, | 434 | "name": "keyword.control.fn.rust" |
435 | { | 435 | }, |
436 | "include": "#sigils" | 436 | "2": { |
437 | }, | 437 | "name": "entity.name.function.rust" |
438 | { | 438 | }, |
439 | "include": "#mut" | 439 | "4": { |
440 | }, | 440 | "name": "punctuation.brackets.round.rust" |
441 | { | 441 | }, |
442 | "include": "#dyn" | 442 | "5": { |
443 | }, | 443 | "name": "punctuation.brackets.angle.rust" |
444 | { | 444 | } |
445 | "include": "#impl" | 445 | }, |
446 | }, | 446 | "end": "\\{", |
447 | { | 447 | "endCaptures": { |
448 | "include": "#lifetime" | 448 | "0": { |
449 | }, | 449 | "name": "punctuation.brackets.curly.rust" |
450 | { | 450 | } |
451 | "include": "#ref_lifetime" | 451 | }, |
452 | }, | 452 | "patterns": [ |
453 | { | 453 | { |
454 | "include": "#core_types" | 454 | "include": "#comments" |
455 | }, | 455 | }, |
456 | { | 456 | { |
457 | "include": "#core_marker" | 457 | "include": "#keywords" |
458 | }, | 458 | }, |
459 | { | 459 | { |
460 | "include": "#core_traits" | 460 | "include": "#lvariables" |
461 | }, | 461 | }, |
462 | { | 462 | { |
463 | "include": "#std_types" | 463 | "include": "#constants" |
464 | }, | 464 | }, |
465 | { | 465 | { |
466 | "include": "#std_traits" | 466 | "include": "#gtypes" |
467 | }, | 467 | }, |
468 | { | 468 | { |
469 | "include": "#type_params" | 469 | "include": "#functions" |
470 | } | 470 | }, |
471 | ] | 471 | { |
472 | } | 472 | "include": "#lifetimes" |
473 | ], | 473 | }, |
474 | "repository": { | 474 | { |
475 | "block_doc_comment": { | 475 | "include": "#macros" |
476 | "comment": "Block documentation comment", | 476 | }, |
477 | "name": "comment.block.documentation.rust", | 477 | { |
478 | "begin": "/\\*[\\*!](?![\\*/])", | 478 | "include": "#namespaces" |
479 | "end": "\\*/", | 479 | }, |
480 | "patterns": [ | 480 | { |
481 | { | 481 | "include": "#punctuation" |
482 | "include": "#block_doc_comment" | 482 | }, |
483 | }, | 483 | { |
484 | { | 484 | "include": "#strings" |
485 | "include": "#block_comment" | 485 | }, |
486 | } | 486 | { |
487 | ] | 487 | "include": "#types" |
488 | }, | 488 | }, |
489 | "block_comment": { | 489 | { |
490 | "comment": "Block comment", | 490 | "include": "#variables" |
491 | "name": "comment.block.rust", | 491 | } |
492 | "begin": "/\\*", | 492 | ] |
493 | "end": "\\*/", | 493 | }, |
494 | "patterns": [ | 494 | { |
495 | { | 495 | "comment": "function/method calls, chaining", |
496 | "include": "#block_doc_comment" | 496 | "name": "meta.function.call.rust", |
497 | }, | 497 | "begin": "(?:(pub)|(?:(\\.)?([A-Za-z0-9_]+)))(\\()", |
498 | { | 498 | "beginCaptures": { |
499 | "include": "#block_comment" | 499 | "1": { |
500 | } | 500 | "name": "keyword.other.rust" |
501 | ] | 501 | }, |
502 | }, | 502 | "2": { |
503 | "line_doc_comment": { | 503 | "name": "keyword.operator.access.dot.rust" |
504 | "comment": "Single-line documentation comment", | 504 | }, |
505 | "name": "comment.line.documentation.rust", | 505 | "3": { |
506 | "begin": "//[!/](?=[^/])", | 506 | "name": "entity.name.function.rust" |
507 | "end": "$" | 507 | }, |
508 | }, | 508 | "4": { |
509 | "line_comment": { | 509 | "name": "punctuation.brackets.round.rust" |
510 | "comment": "Single-line comment", | 510 | } |
511 | "name": "comment.line.double-slash.rust", | 511 | }, |
512 | "begin": "//", | 512 | "end": "\\)", |
513 | "end": "$" | 513 | "endCaptures": { |
514 | }, | 514 | "0": { |
515 | "escaped_character": { | 515 | "name": "punctuation.brackets.round.rust" |
516 | "name": "constant.character.escape.rust", | 516 | } |
517 | "match": "\\\\(x[0-9A-Fa-f]{2}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.)" | 517 | }, |
518 | }, | 518 | "patterns": [ |
519 | "string_literal": { | 519 | { |
520 | "comment": "Double-quote string literal", | 520 | "include": "#comments" |
521 | "name": "string.quoted.double.rust", | 521 | }, |
522 | "begin": "b?\"", | 522 | { |
523 | "end": "\"", | 523 | "include": "#keywords" |
524 | "patterns": [ | 524 | }, |
525 | { | 525 | { |
526 | "include": "#escaped_character" | 526 | "include": "#lvariables" |
527 | } | 527 | }, |
528 | ] | 528 | { |
529 | }, | 529 | "include": "#namespaces" |
530 | "raw_string_literal": { | 530 | }, |
531 | "comment": "Raw double-quote string literal", | 531 | { |
532 | "name": "string.quoted.double.raw.rust", | 532 | "include": "#constants" |
533 | "begin": "b?r(#*)\"", | 533 | }, |
534 | "end": "\"\\1" | 534 | { |
535 | }, | 535 | "include": "#gtypes" |
536 | "sigils": { | 536 | }, |
537 | "comment": "Sigil", | 537 | { |
538 | "name": "keyword.operator.sigil.rust", | 538 | "include": "#functions" |
539 | "match": "[&*](?=[a-zA-Z0-9_\\(\\[\\|\\\"]+)" | 539 | }, |
540 | }, | 540 | { |
541 | "self": { | 541 | "include": "#lifetimes" |
542 | "comment": "Self variable", | 542 | }, |
543 | "name": "variable.language.rust", | 543 | { |
544 | "match": "\\bself\\b" | 544 | "include": "#macros" |
545 | }, | 545 | }, |
546 | "mut": { | 546 | { |
547 | "comment": "Mutable storage modifier", | 547 | "include": "#punctuation" |
548 | "name": "storage.modifier.mut.rust", | 548 | }, |
549 | "match": "\\bmut\\b" | 549 | { |
550 | }, | 550 | "include": "#strings" |
551 | "dyn": { | 551 | }, |
552 | "comment": "Dynamic modifier", | 552 | { |
553 | "name": "storage.modifier.dyn.rust", | 553 | "include": "#types" |
554 | "match": "\\bdyn\\b" | 554 | }, |
555 | }, | 555 | { |
556 | "impl": { | 556 | "include": "#variables" |
557 | "comment": "Existential type modifier", | 557 | } |
558 | "name": "storage.modifier.impl.rust", | 558 | ] |
559 | "match": "\\bimpl\\b" | 559 | } |
560 | }, | 560 | ] |
561 | "box": { | 561 | }, |
562 | "comment": "Box storage modifier", | 562 | "keywords": { |
563 | "name": "storage.modifier.box.rust", | 563 | "patterns": [ |
564 | "match": "\\bbox\\b" | 564 | { |
565 | }, | 565 | "comment": "control flow keywords", |
566 | "const": { | 566 | "name": "keyword.control.rust", |
567 | "comment": "Const storage modifier", | 567 | "match": "\\b(async|await|break|continue|do|else|for|if|loop|match|move|return|try|where|while|yield)\\b" |
568 | "name": "storage.modifier.const.rust", | 568 | }, |
569 | "match": "\\bconst\\b" | 569 | { |
570 | }, | 570 | "comment": "storage keywords", |
571 | "pub": { | 571 | "name": "storage.type.rust", |
572 | "comment": "Visibility modifier", | 572 | "match": "\\b(const|enum|extern|let|macro|mod|struct|trait|type)\\b" |
573 | "name": "storage.modifier.visibility.rust", | 573 | }, |
574 | "match": "\\bpub\\b" | 574 | { |
575 | }, | 575 | "comment": "storage modifiers", |
576 | "unsafe": { | 576 | "name": "storage.modifier.rust", |
577 | "comment": "Unsafe code keyword", | 577 | "match": "\\b(abstract|static)\\b" |
578 | "name": "keyword.other.unsafe.rust", | 578 | }, |
579 | "match": "\\bunsafe\\b" | 579 | { |
580 | }, | 580 | "comment": "other keywords", |
581 | "where": { | 581 | "name": "keyword.other.rust", |
582 | "comment": "Generic where clause", | 582 | "match": "\\b(as|become|box|dyn|final|impl|in|override|priv|pub|ref|typeof|union|unsafe|unsized|use|virtual)\\b" |
583 | "name": "keyword.other.where.rust", | 583 | }, |
584 | "match": "\\bwhere\\b" | 584 | { |
585 | }, | 585 | "comment": "fn", |
586 | "lifetime": { | 586 | "name": "keyword.other.fn.rust", |
587 | "comment": "Named lifetime", | 587 | "match": "\\bfn\\b" |
588 | "name": "storage.modifier.lifetime.rust", | 588 | }, |
589 | "match": "'([a-zA-Z_][a-zA-Z0-9_]*)\\b" | 589 | { |
590 | }, | 590 | "comment": "crate", |
591 | "ref_lifetime": { | 591 | "name": "keyword.other.crate.rust", |
592 | "comment": "Reference with named lifetime", | 592 | "match": "\\bcrate\\b" |
593 | "match": "(&)('[a-zA-Z_][a-zA-Z0-9_]*)\\b", | 593 | }, |
594 | "captures": { | 594 | { |
595 | "1": { | 595 | "comment": "mut", |
596 | "name": "keyword.operator.sigil.rust" | 596 | "name": "storage.modifier.mut.rust", |
597 | }, | 597 | "match": "\\bmut\\b" |
598 | "2": { | 598 | }, |
599 | "name": "storage.modifier.lifetime.rust" | 599 | { |
600 | } | 600 | "comment": "math operators", |
601 | } | 601 | "name": "keyword.operator.math.rust", |
602 | }, | 602 | "match": "(([+%]|(\\*(?!\\w)))(?!=))|(-(?!>))|(/(?!/))" |
603 | "core_types": { | 603 | }, |
604 | "comment": "Built-in/core type", | 604 | { |
605 | "name": "support.type.primitive.rust", | 605 | "comment": "logical operators", |
606 | "match": "\\b(bool|char|usize|isize|u8|u16|u32|u64|u128|i8|i16|i32|i64|i128|f32|f64|str|Self)\\b" | 606 | "name": "keyword.operator.logical.rust", |
607 | }, | 607 | "match": "(\\^|\\||\\|\\||&&|<<|>>|!)(?!=)" |
608 | "core_vars": { | 608 | }, |
609 | "comment": "Core type variant", | 609 | { |
610 | "name": "support.constant.core.rust", | 610 | "comment": "logical AND, borrow references", |
611 | "match": "\\b(Some|None|Ok|Err)\\b" | 611 | "name": "keyword.operator.borrow.and.rust", |
612 | }, | 612 | "match": "&(?![&=])" |
613 | "core_marker": { | 613 | }, |
614 | "comment": "Core trait (marker)", | 614 | { |
615 | "name": "entity.name.type.marker.rust", | 615 | "comment": "assignment operators", |
616 | "match": "\\b(Copy|Send|Sized|Sync)\\b" | 616 | "name": "keyword.operator.assignment.rust", |
617 | }, | 617 | "match": "(-=|\\*=|/=|%=|\\^=|&=|\\|=|<<=|>>=)" |
618 | "core_traits": { | 618 | }, |
619 | "comment": "Core trait", | 619 | { |
620 | "name": "entity.name.type.core.rust", | 620 | "comment": "single equal", |
621 | "match": "\\b(Drop|Fn|FnMut|FnOnce|Clone|PartialEq|PartialOrd|Eq|Ord|AsRef|AsMut|Into|From|Default|Iterator|Extend|IntoIterator|DoubleEndedIterator|ExactSizeIterator)\\b" | 621 | "name": "keyword.operator.assignment.equal.rust", |
622 | }, | 622 | "match": "(?<![<>])=(?!=|>)" |
623 | "std_types": { | 623 | }, |
624 | "comment": "Standard library type", | 624 | { |
625 | "name": "entity.name.type.class.std.rust", | 625 | "comment": "comparison operators", |
626 | "match": "\\b(Box|String|Vec|Path|PathBuf|Option|Result)\\b" | 626 | "name": "keyword.operator.comparison.rust", |
627 | }, | 627 | "match": "(=(=)?(?!>)|!=|<=|(?<!=)>=)" |
628 | "std_traits": { | 628 | }, |
629 | "comment": "Standard library trait", | 629 | { |
630 | "name": "entity.name.type.std.rust", | 630 | "comment": "less than, greater than (special case)", |
631 | "match": "\\b(ToOwned|ToString)\\b" | 631 | "match": "(^|\\s)(?<!=)([<>])\\s", |
632 | }, | 632 | "captures": { |
633 | "type": { | 633 | "2": { |
634 | "comment": "A type", | 634 | "name": "keyword.operator.comparison.rust" |
635 | "name": "entity.name.type.rust", | 635 | } |
636 | "match": "\\b([A-Za-z][_A-Za-z0-9]*|_[_A-Za-z0-9]+)\\b" | 636 | } |
637 | }, | 637 | }, |
638 | "type_params": { | 638 | { |
639 | "comment": "Type parameters", | 639 | "comment": "namespace operator", |
640 | "name": "meta.type_params.rust", | 640 | "name": "keyword.operator.namespace.rust", |
641 | "begin": "<(?![=<])", | 641 | "match": "::" |
642 | "end": "(?<![-])>", | 642 | }, |
643 | "patterns": [ | 643 | { |
644 | { | 644 | "comment": "dereference asterisk", |
645 | "include": "#block_comment" | 645 | "match": "(\\*)(?=\\w+)", |
646 | }, | 646 | "captures": { |
647 | { | 647 | "1": { |
648 | "include": "#line_comment" | 648 | "name": "keyword.operator.dereference.rust" |
649 | }, | 649 | } |
650 | { | 650 | } |
651 | "include": "#sigils" | 651 | }, |
652 | }, | 652 | { |
653 | { | 653 | "comment": "subpattern binding", |
654 | "include": "#mut" | 654 | "name": "keyword.operator.subpattern.rust", |
655 | }, | 655 | "match": "@" |
656 | { | 656 | }, |
657 | "include": "#dyn" | 657 | { |
658 | }, | 658 | "comment": "dot access", |
659 | { | 659 | "name": "keyword.operator.access.dot.rust", |
660 | "include": "#impl" | 660 | "match": "\\.(?!\\.)" |
661 | }, | 661 | }, |
662 | { | 662 | { |
663 | "include": "#lifetime" | 663 | "comment": "ranges, range patterns", |
664 | }, | 664 | "name": "keyword.operator.range.rust", |
665 | { | 665 | "match": "\\.{2}(=|\\.)?" |
666 | "include": "#core_types" | 666 | }, |
667 | }, | 667 | { |
668 | { | 668 | "comment": "colon", |
669 | "include": "#core_marker" | 669 | "name": "keyword.operator.key-value.rust", |
670 | }, | 670 | "match": ":(?!:)" |
671 | { | 671 | }, |
672 | "include": "#core_traits" | 672 | { |
673 | }, | 673 | "comment": "dashrocket, skinny arrow", |
674 | { | 674 | "name": "keyword.operator.arrow.skinny.rust", |
675 | "include": "#std_types" | 675 | "match": "->" |
676 | }, | 676 | }, |
677 | { | 677 | { |
678 | "include": "#std_traits" | 678 | "comment": "hashrocket, fat arrow", |
679 | }, | 679 | "name": "keyword.operator.arrow.fat.rust", |
680 | { | 680 | "match": "=>" |
681 | "include": "#type_params" | 681 | }, |
682 | } | 682 | { |
683 | ] | 683 | "comment": "dollar macros", |
684 | } | 684 | "name": "keyword.operator.macro.dollar.rust", |
685 | } | 685 | "match": "\\$" |
686 | }, | ||
687 | { | ||
688 | "comment": "question mark operator, questionably sized, macro kleene matcher", | ||
689 | "name": "keyword.operator.question.rust", | ||
690 | "match": "\\?" | ||
691 | } | ||
692 | ] | ||
693 | }, | ||
694 | "interpolations": { | ||
695 | "comment": "curly brace interpolations", | ||
696 | "name": "meta.interpolation.rust", | ||
697 | "begin": "{", | ||
698 | "beginCaptures": { | ||
699 | "0": { | ||
700 | "name": "punctuation.definition.interpolation.rust" | ||
701 | } | ||
702 | }, | ||
703 | "end": "}", | ||
704 | "endCaptures": { | ||
705 | "0": { | ||
706 | "name": "punctuation.definition.interpolation.rust" | ||
707 | } | ||
708 | }, | ||
709 | "patterns": [ | ||
710 | { | ||
711 | "include": "#interpolations" | ||
712 | } | ||
713 | ] | ||
714 | }, | ||
715 | "lifetimes": { | ||
716 | "patterns": [ | ||
717 | { | ||
718 | "comment": "named lifetime parameters", | ||
719 | "match": "(['])([a-zA-Z_][0-9a-zA-Z_]*)(?!['])\\b", | ||
720 | "captures": { | ||
721 | "1": { | ||
722 | "name": "punctuation.definition.lifetime.rust" | ||
723 | }, | ||
724 | "2": { | ||
725 | "name": "entity.name.type.lifetime.rust" | ||
726 | } | ||
727 | } | ||
728 | }, | ||
729 | { | ||
730 | "comment": "borrowing references to named lifetimes", | ||
731 | "match": "(\\&)(['])([a-zA-Z_][0-9a-zA-Z_]*)(?!['])\\b", | ||
732 | "captures": { | ||
733 | "1": { | ||
734 | "name": "keyword.operator.borrow.rust" | ||
735 | }, | ||
736 | "2": { | ||
737 | "name": "punctuation.definition.lifetime.rust" | ||
738 | }, | ||
739 | "3": { | ||
740 | "name": "entity.name.type.lifetime.rust" | ||
741 | } | ||
742 | } | ||
743 | } | ||
744 | ] | ||
745 | }, | ||
746 | "macros": { | ||
747 | "patterns": [ | ||
748 | { | ||
749 | "comment": "macros", | ||
750 | "name": "meta.macro.rust", | ||
751 | "match": "(([a-z_][A-Za-z0-9_]*!)|([A-Z_][A-Za-z0-9_]*!))", | ||
752 | "captures": { | ||
753 | "2": { | ||
754 | "name": "entity.name.function.macro.rust" | ||
755 | }, | ||
756 | "3": { | ||
757 | "name": "entity.name.type.macro.rust" | ||
758 | } | ||
759 | } | ||
760 | } | ||
761 | ] | ||
762 | }, | ||
763 | "namespaces": { | ||
764 | "patterns": [ | ||
765 | { | ||
766 | "comment": "namespace (non-type, non-function path segment)", | ||
767 | "match": "(?<![A-Za-z0-9_])([a-z0-9_]+)((?<!super|self)::)", | ||
768 | "captures": { | ||
769 | "1": { | ||
770 | "name": "entity.name.namespace.rust" | ||
771 | }, | ||
772 | "2": { | ||
773 | "name": "keyword.operator.namespace.rust" | ||
774 | } | ||
775 | } | ||
776 | } | ||
777 | ] | ||
778 | }, | ||
779 | "types": { | ||
780 | "patterns": [ | ||
781 | { | ||
782 | "comment": "numeric types", | ||
783 | "match": "(?<![A-Za-z])(f32|f64|i128|i16|i32|i64|i8|isize|u128|u16|u32|u64|u8|usize)\\b", | ||
784 | "captures": { | ||
785 | "1": { | ||
786 | "name": "entity.name.type.numeric.rust" | ||
787 | } | ||
788 | } | ||
789 | }, | ||
790 | { | ||
791 | "comment": "parameterized types", | ||
792 | "begin": "\\b([A-Z][A-Za-z0-9]*)(<)", | ||
793 | "beginCaptures": { | ||
794 | "1": { | ||
795 | "name": "entity.name.type.rust" | ||
796 | }, | ||
797 | "2": { | ||
798 | "name": "punctuation.brackets.angle.rust" | ||
799 | } | ||
800 | }, | ||
801 | "end": ">", | ||
802 | "endCaptures": { | ||
803 | "0": { | ||
804 | "name": "punctuation.brackets.angle.rust" | ||
805 | } | ||
806 | }, | ||
807 | "patterns": [ | ||
808 | { | ||
809 | "include": "#comments" | ||
810 | }, | ||
811 | { | ||
812 | "include": "#keywords" | ||
813 | }, | ||
814 | { | ||
815 | "include": "#lvariables" | ||
816 | }, | ||
817 | { | ||
818 | "include": "#lifetimes" | ||
819 | }, | ||
820 | { | ||
821 | "include": "#punctuation" | ||
822 | }, | ||
823 | { | ||
824 | "include": "#types" | ||
825 | }, | ||
826 | { | ||
827 | "include": "#variables" | ||
828 | } | ||
829 | ] | ||
830 | }, | ||
831 | { | ||
832 | "comment": "primitive types", | ||
833 | "name": "entity.name.type.primitive.rust", | ||
834 | "match": "\\b(bool|char|str)\\b" | ||
835 | }, | ||
836 | { | ||
837 | "comment": "trait declarations", | ||
838 | "match": "\\b(trait)\\s+([A-Z][A-Za-z0-9]*)\\b", | ||
839 | "captures": { | ||
840 | "1": { | ||
841 | "name": "storage.type.rust" | ||
842 | }, | ||
843 | "2": { | ||
844 | "name": "entity.name.type.trait.rust" | ||
845 | } | ||
846 | } | ||
847 | }, | ||
848 | { | ||
849 | "comment": "struct declarations", | ||
850 | "match": "\\b(struct)\\s+([A-Z][A-Za-z0-9]*)\\b", | ||
851 | "captures": { | ||
852 | "1": { | ||
853 | "name": "storage.type.rust" | ||
854 | }, | ||
855 | "2": { | ||
856 | "name": "entity.name.type.struct.rust" | ||
857 | } | ||
858 | } | ||
859 | }, | ||
860 | { | ||
861 | "comment": "enum declarations", | ||
862 | "match": "\\b(enum)\\s+([A-Z][A-Za-z0-9_]*)\\b", | ||
863 | "captures": { | ||
864 | "1": { | ||
865 | "name": "storage.type.rust" | ||
866 | }, | ||
867 | "2": { | ||
868 | "name": "entity.name.type.enum.rust" | ||
869 | } | ||
870 | } | ||
871 | }, | ||
872 | { | ||
873 | "comment": "type declarations", | ||
874 | "match": "\\b(type)\\s+([A-Z][A-Za-z0-9_]*)\\b", | ||
875 | "captures": { | ||
876 | "1": { | ||
877 | "name": "storage.type.rust" | ||
878 | }, | ||
879 | "2": { | ||
880 | "name": "entity.name.type.declaration.rust" | ||
881 | } | ||
882 | } | ||
883 | }, | ||
884 | { | ||
885 | "comment": "types", | ||
886 | "name": "entity.name.type.rust", | ||
887 | "match": "\\b[A-Z][A-Za-z0-9]*\\b(?!!)" | ||
888 | } | ||
889 | ] | ||
890 | }, | ||
891 | "gtypes": { | ||
892 | "patterns": [ | ||
893 | { | ||
894 | "comment": "option types", | ||
895 | "name": "entity.name.type.option.rust", | ||
896 | "match": "\\b(Some|None)\\b" | ||
897 | }, | ||
898 | { | ||
899 | "comment": "result types", | ||
900 | "name": "entity.name.type.result.rust", | ||
901 | "match": "\\b(Ok|Err)\\b" | ||
902 | } | ||
903 | ] | ||
904 | }, | ||
905 | "punctuation": { | ||
906 | "patterns": [ | ||
907 | { | ||
908 | "comment": "comma", | ||
909 | "name": "punctuation.comma.rust", | ||
910 | "match": "," | ||
911 | }, | ||
912 | { | ||
913 | "comment": "curly braces", | ||
914 | "name": "punctuation.brackets.curly.rust", | ||
915 | "match": "[{}]" | ||
916 | }, | ||
917 | { | ||
918 | "comment": "parentheses, round brackets", | ||
919 | "name": "punctuation.brackets.round.rust", | ||
920 | "match": "[()]" | ||
921 | }, | ||
922 | { | ||
923 | "comment": "semicolon", | ||
924 | "name": "punctuation.semi.rust", | ||
925 | "match": ";" | ||
926 | }, | ||
927 | { | ||
928 | "comment": "square brackets", | ||
929 | "name": "punctuation.brackets.square.rust", | ||
930 | "match": "[\\[\\]]" | ||
931 | }, | ||
932 | { | ||
933 | "comment": "angle brackets", | ||
934 | "name": "punctuation.brackets.angle.rust", | ||
935 | "match": "(?<!=)[<>]" | ||
936 | } | ||
937 | ] | ||
938 | }, | ||
939 | "strings": { | ||
940 | "patterns": [ | ||
941 | { | ||
942 | "comment": "double-quoted strings and byte strings", | ||
943 | "name": "string.quoted.double.rust", | ||
944 | "begin": "(b?)(\")", | ||
945 | "beginCaptures": { | ||
946 | "1": { | ||
947 | "name": "string.quoted.byte.raw.rust" | ||
948 | }, | ||
949 | "2": { | ||
950 | "name": "punctuation.definition.string.rust" | ||
951 | } | ||
952 | }, | ||
953 | "end": "\"", | ||
954 | "endCaptures": { | ||
955 | "0": { | ||
956 | "name": "punctuation.definition.string.rust" | ||
957 | } | ||
958 | }, | ||
959 | "patterns": [ | ||
960 | { | ||
961 | "include": "#escapes" | ||
962 | }, | ||
963 | { | ||
964 | "include": "#interpolations" | ||
965 | } | ||
966 | ] | ||
967 | }, | ||
968 | { | ||
969 | "comment": "double-quoted raw strings and raw byte strings", | ||
970 | "name": "string.quoted.double.rust", | ||
971 | "begin": "(b?r)(#*)(\")", | ||
972 | "beginCaptures": { | ||
973 | "1": { | ||
974 | "name": "string.quoted.byte.raw.rust" | ||
975 | }, | ||
976 | "2": { | ||
977 | "name": "punctuation.definition.string.raw.rust" | ||
978 | }, | ||
979 | "3": { | ||
980 | "name": "punctuation.definition.string.rust" | ||
981 | } | ||
982 | }, | ||
983 | "end": "(\")(#*)", | ||
984 | "endCaptures": { | ||
985 | "1": { | ||
986 | "name": "punctuation.definition.string.rust" | ||
987 | }, | ||
988 | "2": { | ||
989 | "name": "punctuation.definition.string.raw.rust" | ||
990 | } | ||
991 | } | ||
992 | }, | ||
993 | { | ||
994 | "comment": "characters and bytes", | ||
995 | "name": "string.quoted.single.char.rust", | ||
996 | "begin": "(b)?(')", | ||
997 | "beginCaptures": { | ||
998 | "1": { | ||
999 | "name": "string.quoted.byte.raw.rust" | ||
1000 | }, | ||
1001 | "2": { | ||
1002 | "name": "punctuation.definition.char.rust" | ||
1003 | } | ||
1004 | }, | ||
1005 | "end": "'", | ||
1006 | "endCaptures": { | ||
1007 | "0": { | ||
1008 | "name": "punctuation.definition.char.rust" | ||
1009 | } | ||
1010 | }, | ||
1011 | "patterns": [ | ||
1012 | { | ||
1013 | "include": "#escapes" | ||
1014 | } | ||
1015 | ] | ||
1016 | } | ||
1017 | ] | ||
1018 | }, | ||
1019 | "lvariables": { | ||
1020 | "patterns": [ | ||
1021 | { | ||
1022 | "comment": "self", | ||
1023 | "name": "variable.language.self.rust", | ||
1024 | "match": "\\b[Ss]elf\\b" | ||
1025 | }, | ||
1026 | { | ||
1027 | "comment": "super", | ||
1028 | "name": "variable.language.super.rust", | ||
1029 | "match": "\\bsuper\\b" | ||
1030 | } | ||
1031 | ] | ||
1032 | }, | ||
1033 | "variables": { | ||
1034 | "patterns": [ | ||
1035 | { | ||
1036 | "comment": "variables", | ||
1037 | "name": "variable.other.rust", | ||
1038 | "match": "\\b(?<!\\.)[a-z0-9_]+\\b" | ||
1039 | } | ||
1040 | ] | ||
1041 | } | ||
1042 | } | ||
686 | } | 1043 | } |
diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts index 1a90f1b7d..1445e41d3 100644 --- a/editors/code/src/commands.ts +++ b/editors/code/src/commands.ts | |||
@@ -419,10 +419,31 @@ export function gotoLocation(ctx: Ctx): Cmd { | |||
419 | }; | 419 | }; |
420 | } | 420 | } |
421 | 421 | ||
422 | export function openDocs(ctx: Ctx): Cmd { | ||
423 | return async () => { | ||
424 | |||
425 | const client = ctx.client; | ||
426 | const editor = vscode.window.activeTextEditor; | ||
427 | if (!editor || !client) { | ||
428 | return; | ||
429 | }; | ||
430 | |||
431 | const position = editor.selection.active; | ||
432 | const textDocument = { uri: editor.document.uri.toString() }; | ||
433 | |||
434 | const doclink = await client.sendRequest(ra.openDocs, { position, textDocument }); | ||
435 | |||
436 | if (doclink != null) { | ||
437 | vscode.commands.executeCommand("vscode.open", vscode.Uri.parse(doclink)); | ||
438 | } | ||
439 | }; | ||
440 | |||
441 | } | ||
442 | |||
422 | export function resolveCodeAction(ctx: Ctx): Cmd { | 443 | export function resolveCodeAction(ctx: Ctx): Cmd { |
423 | const client = ctx.client; | 444 | const client = ctx.client; |
424 | return async (params: ra.ResolveCodeActionParams) => { | 445 | return async () => { |
425 | const item: lc.WorkspaceEdit = await client.sendRequest(ra.resolveCodeAction, params); | 446 | const item: lc.WorkspaceEdit = await client.sendRequest(ra.resolveCodeAction, null); |
426 | if (!item) { | 447 | if (!item) { |
427 | return; | 448 | return; |
428 | } | 449 | } |
diff --git a/editors/code/src/lsp_ext.ts b/editors/code/src/lsp_ext.ts index f286b68a6..fc8e120b3 100644 --- a/editors/code/src/lsp_ext.ts +++ b/editors/code/src/lsp_ext.ts | |||
@@ -118,3 +118,5 @@ export interface CommandLinkGroup { | |||
118 | title?: string; | 118 | title?: string; |
119 | commands: CommandLink[]; | 119 | commands: CommandLink[]; |
120 | } | 120 | } |
121 | |||
122 | export const openDocs = new lc.RequestType<lc.TextDocumentPositionParams, string | void, void>('experimental/externalDocs'); | ||
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index 2896d90ac..09543e348 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts | |||
@@ -110,6 +110,7 @@ async function tryActivate(context: vscode.ExtensionContext) { | |||
110 | ctx.registerCommand('run', commands.run); | 110 | ctx.registerCommand('run', commands.run); |
111 | ctx.registerCommand('debug', commands.debug); | 111 | ctx.registerCommand('debug', commands.debug); |
112 | ctx.registerCommand('newDebugConfig', commands.newDebugConfig); | 112 | ctx.registerCommand('newDebugConfig', commands.newDebugConfig); |
113 | ctx.registerCommand('openDocs', commands.openDocs); | ||
113 | 114 | ||
114 | defaultOnEnter.dispose(); | 115 | defaultOnEnter.dispose(); |
115 | ctx.registerCommand('onEnter', commands.onEnter); | 116 | ctx.registerCommand('onEnter', commands.onEnter); |