├── package-metadata.json
├── README.md
├── Comments.tmPreferences
├── vlang.JSON-tmLanguage
└── vlang.tmLanguage
/package-metadata.json:
--------------------------------------------------------------------------------
1 | {
2 | "platforms": [
3 | "*"
4 | ],
5 | "description": "A Sublime text 3 basic syntax highlighter for Vlang development.",
6 | "dependencies": [],
7 | "sublime_text": "*",
8 | "url": "https://github.com/oversoul/vlang-sublime",
9 | "version": "0.1"
10 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Sublime text 3 Support for the Vlang Programming Language
2 |
3 | This bundle provides [Vlang](https://vlang.io/) syntax highlighting. for Sublime text editor.
4 |
5 | # Installing the Sublime Bundle
6 |
7 | cd ~/.config/sublime-text-3/Packages/User
8 | git clone https://github.com/oversoul/vlang-sublime
9 |
--------------------------------------------------------------------------------
/Comments.tmPreferences:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | scope
5 | source.v
6 | settings
7 |
8 | shellVariables
9 |
10 |
11 | name
12 | TM_COMMENT_START
13 | value
14 | //
15 |
16 |
17 | name
18 | TM_COMMENT_START_2
19 | value
20 | /*
21 |
22 |
23 | name
24 | TM_COMMENT_END_2
25 | value
26 | */
27 |
28 |
29 | name
30 | TM_COMMENT_DISABLE_INDENT_2
31 | value
32 | yes
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/vlang.JSON-tmLanguage:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vlang",
3 | "scopeName": "source.v",
4 | "fileTypes": [
5 | "v"
6 | ],
7 | "uuid": "ca9f2cc0-a834-40aa-8987-3ef92dbc7517",
8 | "patterns": [
9 | {
10 | "include": "#comments"
11 | },
12 | {
13 | "include": "#as-is"
14 | },
15 | {
16 | "include": "#constants"
17 | },
18 | {
19 | "include": "#string-placeholder"
20 | },
21 | {
22 | "include": "#illegal-name"
23 | },
24 | {
25 | "include": "#strings"
26 | },
27 | {
28 | "include": "#string-escaped-char"
29 | },
30 | {
31 | "include": "#numbers"
32 | },
33 | {
34 | "include": "#operators"
35 | },
36 | {
37 | "include": "#types"
38 | },
39 | {
40 | "include": "#storage"
41 | },
42 | {
43 | "include": "#keywords"
44 | },
45 | {
46 | "include": "#punctuation"
47 | },
48 | {
49 | "include": "#struct-access-modifier"
50 | },
51 | {
52 | "include": "#interface"
53 | },
54 | {
55 | "include": "#enum"
56 | },
57 | {
58 | "include": "#type"
59 | },
60 | {
61 | "include": "#function-exist"
62 | },
63 | {
64 | "include": "#generic"
65 | },
66 | {
67 | "include": "#escaped-fix"
68 | },
69 | {
70 | "include": "#builtin-fix"
71 | },
72 | {
73 | "include": "#brackets"
74 | },
75 | {
76 | "include": "#flag-decl"
77 | },
78 | {
79 | "include": "#include-decl"
80 | },
81 | {
82 | "include": "#import-decl"
83 | },
84 | {
85 | "include": "#module-decl"
86 | },
87 | {
88 | "include": "#attributes"
89 | },
90 | {
91 | "include": "#assignment"
92 | },
93 | {
94 | "include": "#module-func-call"
95 | }
96 | ],
97 | "repository": {
98 | "module-func-call": {
99 | "name": "module.function.call.v",
100 | "match": "\\s*(\\w+)\\.\\w+",
101 | "captures": {
102 | "1": { "name": "constant.numeric.integer.v" }
103 | }
104 | },
105 | "comments": {
106 | "patterns": [
107 | {
108 | "name": "comment.block.documentation.v",
109 | "begin": "/\\*",
110 | "beginCaptures": {
111 | "0": {
112 | "name": "punctuation.definition.comment.begin.v"
113 | }
114 | },
115 | "end": "\\*/",
116 | "endCaptures": {
117 | "0": {
118 | "name": "punctuation.definition.comment.end.v"
119 | }
120 | },
121 | "patterns": [
122 | {
123 | "include": "#comments"
124 | }
125 | ]
126 | },
127 | {
128 | "name": "comment.line.double-slash.v",
129 | "begin": "//",
130 | "beginCaptures": {
131 | "0": {
132 | "name": "punctuation.definition.comment.begin.v"
133 | }
134 | },
135 | "end": "$"
136 | }
137 | ]
138 | },
139 | "as-is": {
140 | "begin": "\\s+(as|is)\\s+",
141 | "beginCaptures": {
142 | "1": {
143 | "name": "keyword.$1.v"
144 | }
145 | },
146 | "end": "([\\w.]*)",
147 | "endCaptures": {
148 | "1": {
149 | "name": "entity.name.alias.v"
150 | }
151 | }
152 | },
153 | "constants": {
154 | "name": "constant.language.v",
155 | "match": "\\b(true|false)\\b"
156 | },
157 |
158 | "assignment": {
159 | "name": "meta.definition.variable.v",
160 | "match": "([\\w.]+)\\s*((?:\\:\\=|\\+\\=|\\-\\=|\\*\\=|\\/\\=|\\%\\=|\\&\\=|\\|\\=|\\^\\=))\\s*(?=.+)",
161 | "captures": {
162 | "1": {
163 | "name": "variable.assignment.other.v"
164 | }
165 | }
166 | },
167 |
168 | "struct": {
169 | "patterns": [
170 | {
171 | "name": "meta.definition.struct.v",
172 | "begin": "^\\s*(?:(mut|var|pub(?:\\s+mut|var)?|__global)\\s+)?(struct)\\s+([\\w.]+)\\s*({)",
173 | "beginCaptures": {
174 | "1": {
175 | "name": "storage.modifier.$1.v"
176 | },
177 | "2": {
178 | "name": "storage.type.struct.v"
179 | },
180 | "3": {
181 | "name": "entity.name.struct.v"
182 | },
183 | "4": {
184 | "name": "punctuation.definition.bracket.curly.begin.v"
185 | }
186 | },
187 | "end": "\\s*(})",
188 | "endCaptures": {
189 | "1": {
190 | "name": "punctuation.definition.bracket.curly.end.v"
191 | }
192 | },
193 | "patterns": [
194 | {
195 | "include": "#struct-access-modifier"
196 | },
197 | {
198 | "match": "\\b(\\w+)\\s+([\\w\\[\\]\\*&.]+)(?:\\s*(=)\\s*((?:.(?=$|//|/\\*))*+))?",
199 | "captures": {
200 | "1": {
201 | "name": "variable.other.property.v"
202 | },
203 | "3": {
204 | "name": "keyword.operator.assignment.v"
205 | }
206 | }
207 | },
208 | {
209 | "include": "#types"
210 | },
211 | {
212 | "include": "$self"
213 | }
214 | ]
215 | },
216 | {
217 | "name": "meta.definition.struct.v",
218 | "match": "^\\s*(?:(mut|var|pub(?:\\s+mut|var)?|__global)\\s+)?(struct)(?:\\s+([\\w.]+))?",
219 | "captures": {
220 | "1": {
221 | "name": "storage.modifier.$1.v"
222 | },
223 | "2": {
224 | "name": "storage.type.struct.v"
225 | },
226 | "3": {
227 | "name": "entity.name.struct.v"
228 | }
229 | }
230 | }
231 | ]
232 | },
233 |
234 |
235 | "attributes": {
236 | "name": "meta.definition.attribute.v",
237 | "match": "^\\s*((\\[)(deprecated|unsafe_fn|typedef|live|inline|flag)(\\]))",
238 | "captures": {
239 | "1": {
240 | "name": "meta.function.attribute.v"
241 | },
242 | "2": {
243 | "name": "punctuation.definition.begin.bracket.square.v"
244 | },
245 | "3": {
246 | "name": "storage.modifier.attribute.v"
247 | },
248 | "4": {
249 | "name": "punctuation.definition.end.bracket.square.v"
250 | }
251 | }
252 | },
253 | "module-decl": {
254 | "name": "meta.module.v",
255 | "begin": "^\\s*(module)\\s+",
256 | "beginCaptures": {
257 | "1": {
258 | "name": "keyword.module.v"
259 | }
260 | },
261 | "end": "([\\w.]+)",
262 | "endCaptures": {
263 | "1": {
264 | "name": "entity.name.module.v"
265 | }
266 | }
267 | },
268 | "import-decl": {
269 | "name": "meta.import.v",
270 | "begin": "^\\s*(import)\\s+",
271 | "beginCaptures": {
272 | "1": {
273 | "name": "keyword.import.v"
274 | }
275 | },
276 | "end": "([\\w.]+)",
277 | "endCaptures": {
278 | "1": {
279 | "name": "entity.name.import.v"
280 | }
281 | }
282 | },
283 | "include-decl": {
284 | "name": "meta.include.v",
285 | "begin": "^\\s*(#include)",
286 | "beginCaptures": {
287 | "1": {
288 | "name": "keyword.include.v"
289 | }
290 | },
291 | "end": "\\s+(([\\<\"])\\s*(.*)([\\>\"]))",
292 | "endCaptures": {
293 | "1": {
294 | "name": "string.quoted.double.v"
295 | }
296 | }
297 | },
298 |
299 | "flag-decl": {
300 | "name": "meta.flag.v",
301 | "begin": "^\\s*(#flag)",
302 | "beginCaptures": {
303 | "1": {
304 | "name": "keyword.flag.v"
305 | }
306 | },
307 | "end": "\\s+(.*?)$",
308 | "endCaptures": {
309 | "1": {
310 | "name": "string.quoted.single.v"
311 | }
312 | }
313 | },
314 | "brackets": {
315 | "patterns": [
316 | {
317 | "begin": "{",
318 | "beginCaptures": {
319 | "0": {
320 | "name": "punctuation.definition.bracket.curly.begin.v"
321 | }
322 | },
323 | "end": "}",
324 | "endCaptures": {
325 | "0": {
326 | "name": "punctuation.definition.bracket.curly.end.v"
327 | }
328 | },
329 | "patterns": [
330 | {
331 | "include": "$self"
332 | }
333 | ]
334 | },
335 | {
336 | "begin": "\\(",
337 | "beginCaptures": {
338 | "0": {
339 | "name": "punctuation.definition.bracket.round.begin.v"
340 | }
341 | },
342 | "end": "\\)",
343 | "endCaptures": {
344 | "0": {
345 | "name": "punctuation.definition.bracket.round.end.v"
346 | }
347 | },
348 | "patterns": [
349 | {
350 | "include": "$self"
351 | }
352 | ]
353 | },
354 | {
355 | "begin": "\\[",
356 | "beginCaptures": {
357 | "0": {
358 | "name": "punctuation.definition.bracket.square.begin.v"
359 | }
360 | },
361 | "end": "\\]",
362 | "endCaptures": {
363 | "0": {
364 | "name": "punctuation.definition.bracket.square.end.v"
365 | }
366 | },
367 | "patterns": [
368 | {
369 | "include": "$self"
370 | }
371 | ]
372 | }
373 | ]
374 | },
375 | "builtin-fix": {
376 | "patterns": [
377 | {
378 | "patterns": [
379 | {
380 | "name": "storage.modifier.v",
381 | "match": "(const)(?=\\s*\\()"
382 | },
383 | {
384 | "name": "keyword.$1.v",
385 | "match": "\\b(fn|type|enum|struct|interface|map|assert|sizeof)\\b(?=\\s*\\()"
386 | }
387 | ]
388 | },
389 | {
390 | "patterns": [
391 | {
392 | "name": "keyword.control.v",
393 | "match": "(\\$if|\\$else)(?=\\s*\\()"
394 | },
395 | {
396 | "name": "keyword.control.v",
397 | "match": "\\b(in|is|or|break|continue|default|unsafe|match|if|else|for|go|goto|defer|return)\\b(?=\\s*\\()"
398 | }
399 | ]
400 | },
401 | {
402 | "patterns": [
403 | {
404 | "match": "(i?(?:8|16|nt|64|128)|u?(?:16|32|64|128)|f?(?:32|64))(?=\\s*\\()",
405 | "captures": {
406 | "1": {
407 | "name": "storage.type.numeric.v"
408 | }
409 | },
410 | "name": "meta.expr.numeric.cast.v"
411 | },
412 | {
413 | "match": "(bool|byte|byteptr|charptr|voidptr|string|ustring|rune|none)(?=\\s*\\()",
414 | "captures": {
415 | "1": {
416 | "name": "storage.type.$1.v"
417 | }
418 | },
419 | "name": "meta.expr.bool.cast.v"
420 | }
421 | ]
422 | }
423 | ]
424 | },
425 | "escaped-fix": {
426 | "name": "meta.escaped.keyword.v",
427 | "match": "((?:@)(?:mut|var|pub|fn|unsafe|module|import|as|const|map|assert|sizeof|type|struct|interface|enum|in|is|or|match|if|else|for|go|goto|defer|return|i?(?:8|16|nt|64|128)|u?(?:16|32|64|128)|f?(?:32|64)|bool|byte|byteptr|charptr|voidptr|string|ustring|rune|none))",
428 | "captures": {
429 | "0": {
430 | "name": "keyword.other.escaped.v"
431 | }
432 | }
433 | },
434 | "generic": {
435 | "patterns": [
436 | {
437 | "name": "meta.definition.generic.v",
438 | "match": "(?<=[\\w\\s+])(\\<)(\\w+)(\\>)",
439 | "captures": {
440 | "1": {
441 | "name": "punctuation.definition.bracket.angle.begin.v"
442 | },
443 | // "2": {
444 | // "patterns": [
445 | // {
446 | // "include": "#illegal-name"
447 | // },
448 | // {
449 | // "match": "\\w+",
450 | // "name": "entity.name.generic.v"
451 | // }
452 | // ]
453 | // },
454 | "3": {
455 | "name": "punctuation.definition.bracket.angle.end.v"
456 | }
457 | }
458 | }
459 | ]
460 | },
461 | "function-exist": {
462 | "name": "meta.support.function.v",
463 | "match": "(\\w+)((?<=[\\w\\s+])(\\<)(\\w+)(\\>))?(?=\\s*\\()",
464 | "captures": {
465 | "0": {
466 | "name": "meta.function.call.v"
467 | }
468 | // "1": {
469 | // "patterns": [
470 | // {
471 | // "include": "#illegal-name"
472 | // },
473 | // {
474 | // "match": "\\w+",
475 | // "name": "entity.name.function.v"
476 | // }
477 | // ]
478 | // },
479 | // "2": {
480 | // "patterns": [
481 | // {
482 | // "include": "#generic"
483 | // }
484 | // ]
485 | // }
486 | }
487 | },
488 | "type": {
489 | "name": "meta.definition.type.v",
490 | "match": "^\\s*(?:(pub)?\\s+)?(type)\\s+(\\w*)\\s+(?:\\w+\\.+)?(\\w*)",
491 | "captures": {
492 | "1": {
493 | "name": "storage.modifier.$1.v"
494 | },
495 | "2": {
496 | "name": "storage.type.type.v"
497 | }
498 | // "3": {
499 | // "patterns": [
500 | // {
501 | // "include": "#illegal-name"
502 | // },
503 | // {
504 | // "include": "#types"
505 | // },
506 | // {
507 | // "name": "entity.name.type.v",
508 | // "match": "\\w+"
509 | // }
510 | // ]
511 | // },
512 | // "4": {
513 | // "patterns": [
514 | // {
515 | // "include": "#illegal-name"
516 | // },
517 | // {
518 | // "include": "#types"
519 | // },
520 | // {
521 | // "name": "entity.name.type.v",
522 | // "match": "\\w+"
523 | // }
524 | // ]
525 | // }
526 | }
527 | },
528 | "enum": {
529 | "name": "meta.definition.enum.v",
530 | "match": "^\\s*(?:(pub)?\\s+)?(enum)\\s+(?:\\w+\\.)?(\\w*)",
531 | "captures": {
532 | "1": {
533 | "name": "storage.modifier.$1.v"
534 | },
535 | "2": {
536 | "name": "storage.type.enum.v"
537 | },
538 | "3": {
539 | "name": "entity.name.enum.v"
540 | }
541 | }
542 | },
543 | "interface": {
544 | "name": "meta.definition.interface.v",
545 | "match": "^\\s*(?:(pub)?\\s+)?(interface)\\s+(\\w*)",
546 | "captures": {
547 | "1": {
548 | "name": "storage.modifier.$1.v"
549 | },
550 | "2": {
551 | "name": "keyword.interface.v"
552 | }
553 | // "3": {
554 | // "patterns": [
555 | // {
556 | // "include": "#illegal-name"
557 | // },
558 | // {
559 | // "name": "entity.name.interface.v",
560 | // "match": "\\w+"
561 | // }
562 | // ]
563 | // }
564 | }
565 | },
566 | "struct-access-modifier": {
567 | "match": "(?<=\\s|^)(mut|var|pub(?:\\s+mut|var)?|__global)(:|\\b)",
568 | "captures": {
569 | "1": {
570 | "name": "storage.modifier.$1.v"
571 | },
572 | "2": {
573 | "name": "punctuation.separator.struct.key-value.v"
574 | }
575 | }
576 | },
577 | "punctuation": {
578 | "patterns": [
579 | {
580 | "name": "punctuation.delimiter.period.dot.v",
581 | "match": "\\."
582 | },
583 | {
584 | "name": "punctuation.delimiter.comma.v",
585 | "match": ","
586 | },
587 | {
588 | "name": "punctuation.separator.key-value.colon.v",
589 | "match": ":"
590 | },
591 | {
592 | "name": "punctuation.definition.other.semicolon.v",
593 | "match": ";"
594 | },
595 | {
596 | "name": "punctuation.definition.other.questionmark.v",
597 | "match": "\\?"
598 | }
599 | ]
600 | },
601 | "keywords": {
602 | "patterns": [
603 | {
604 | "name": "keyword.control.v",
605 | "match": "(\\$if|\\$else)"
606 | },
607 | {
608 | "name": "keyword.control.v",
609 | "match": "\\b(in|is|or|break|continue|default|unsafe|match|if|else|for|go|goto|defer|return)\\b"
610 | },
611 | {
612 | "name": "keyword.$1.v",
613 | "match": "\\b(fn|type|enum|struct|interface|map|assert|sizeof)\\b"
614 | }
615 | ]
616 | },
617 | "storage": {
618 | "name": "storage.modifier.v",
619 | "match": "\\b(const|mut|var|pub)\\b"
620 | },
621 | "types": {
622 | "patterns": [
623 | {
624 | "name": "storage.type.numeric.v",
625 | "match": "\\b(i(8|16|nt|64|128)|u(8|16|32|64|128)|f(32|64))\\b"
626 | },
627 | {
628 | "name": "storage.type.$1.v",
629 | "match": "\\b(bool|byte|byteptr|charptr|voidptr|string|ustring|rune|none)\\b"
630 | }
631 | ]
632 | },
633 | "operators": {
634 | "patterns": [
635 | {
636 | "name": "keyword.operator.relation.v",
637 | "match": "(\\=\\=|\\!\\=|\\>|\\<|\\>\\=|\\<\\=)"
638 | },
639 | {
640 | "name": "keyword.operator.arithmethic.v",
641 | "match": "(\\+|\\-|\\*|\\/|\\%|\\+\\+|\\-\\-)"
642 | },
643 | {
644 | "name": "keyword.operator.assignment.v",
645 | "match": "(\\:\\=|\\=|\\+\\=|\\-\\=|\\*\\=|\\/\\=|\\%\\=|\\&\\=|\\|\\=|\\^\\=|\\&\\&\\=|\\|\\|\\=|\\>\\>\\=|\\<\\<\\=)"
646 | },
647 | {
648 | "name": "keyword.operator.bitwise.v",
649 | "match": "(\\&|\\||\\^|<(?!<)|>(?!>))"
650 | },
651 | {
652 | "name": "keyword.operator.logical.v",
653 | "match": "(\\&\\&|\\|\\||\\!)"
654 | }
655 | ]
656 | },
657 | "numbers": {
658 | "patterns": [
659 | {
660 | "name": "constant.numeric.float.v",
661 | "match": "(?:(?:[-]?)(?:[0-9e]*)(?:[.]){1}(?:[0-9]+))"
662 | },
663 | {
664 | "name": "constant.numeric.hex.v",
665 | "match": "\\b(?:0[xX])(?:[0-9a-fA-F]+)"
666 | },
667 | {
668 | "name": "constant.numeric.integer.v",
669 | "match": "\\b(?:[-]?)(?:[0-9]+)"
670 | }
671 | ]
672 | },
673 | "strings": {
674 | "patterns": [
675 | {
676 | "begin": "`",
677 | "beginCaptures": {
678 | "0": {
679 | "name": "punctuation.definition.string.raw.begin.v"
680 | }
681 | },
682 | "end": "`",
683 | "endCaptures": {
684 | "0": {
685 | "name": "punctuation.definition.string.raw.end.v"
686 | }
687 | },
688 | "name": "string.quoted.raw.v",
689 | "patterns": [
690 | {
691 | "include": "#string-escaped-char"
692 | },
693 | {
694 | "include": "#string-interpolation"
695 | },
696 | {
697 | "include": "#string-placeholder"
698 | }
699 | ]
700 | },
701 | {
702 | "begin": "'",
703 | "beginCaptures": {
704 | "0": {
705 | "name": "punctuation.definition.string.single.begin.v"
706 | }
707 | },
708 | "end": "'",
709 | "endCaptures": {
710 | "0": {
711 | "name": "punctuation.definition.string.single.end.v"
712 | }
713 | },
714 | "name": "string.quoted.single.v",
715 | "patterns": [
716 | {
717 | "include": "#string-escaped-char"
718 | },
719 | {
720 | "include": "#string-interpolation"
721 | },
722 | {
723 | "include": "#string-placeholder"
724 | }
725 | ]
726 | },
727 | {
728 | "begin": "\"",
729 | "beginCaptures": {
730 | "0": {
731 | "name": "punctuation.definition.string.double.begin.v"
732 | }
733 | },
734 | "end": "\"",
735 | "endCaptures": {
736 | "0": {
737 | "name": "punctuation.definition.string.double.end.v"
738 | }
739 | },
740 | "name": "string.quoted.double.v",
741 | "patterns": [
742 | {
743 | "include": "#string-escaped-char"
744 | },
745 | {
746 | "include": "#string-interpolation"
747 | },
748 | {
749 | "include": "#string-placeholder"
750 | }
751 | ]
752 | }
753 | ]
754 | },
755 | "string-escaped-char": {
756 | "patterns": [
757 | {
758 | "name": "constant.character.escape.v",
759 | "match": "\\\\([0-7]{3}|[\\$abfnrtv\\\\'\"]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})"
760 | },
761 | {
762 | "name": "invalid.illegal.unknown-escape.v",
763 | "match": "\\\\[^0-7\\$xuUabfnrtv\\'\"]"
764 | }
765 | ]
766 | },
767 | "string-escaped-char": {
768 | "patterns": [
769 | {
770 | "name": "constant.character.escape.v",
771 | "match": "\\\\([0-7]{3}|[\\$abfnrtv\\\\'\"]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})"
772 | },
773 | {
774 | "name": "invalid.illegal.unknown-escape.v",
775 | "match": "\\\\[^0-7\\$xuUabfnrtv\\'\"]"
776 | }
777 | ]
778 | },
779 | "string-placeholder": {
780 | "match": "%(\\[\\d+\\])?([\\+#\\-0\\x20]{,2}((\\d+|\\*)?(\\.?(\\d+|\\*|(\\[\\d+\\])\\*?)?(\\[\\d+\\])?)?))?[vT%tbcdoqxXUbeEfFgGsp]",
781 | "name": "constant.other.placeholder.v"
782 | }
783 | // "illegal-name": {
784 | // "match": "\\d\\w+",
785 | // "name": "invalid.illegal.v"
786 | // }
787 | }
788 | }
--------------------------------------------------------------------------------
/vlang.tmLanguage:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | fileTypes
6 |
7 | v
8 |
9 | name
10 | vlang
11 | patterns
12 |
13 |
14 | include
15 | #comments
16 |
17 |
18 | include
19 | #as-is
20 |
21 |
22 | include
23 | #constants
24 |
25 |
26 | include
27 | #string-placeholder
28 |
29 |
30 | include
31 | #illegal-name
32 |
33 |
34 | include
35 | #strings
36 |
37 |
38 | include
39 | #string-escaped-char
40 |
41 |
42 | include
43 | #numbers
44 |
45 |
46 | include
47 | #operators
48 |
49 |
50 | include
51 | #types
52 |
53 |
54 | include
55 | #storage
56 |
57 |
58 | include
59 | #keywords
60 |
61 |
62 | include
63 | #punctuation
64 |
65 |
66 | include
67 | #struct-access-modifier
68 |
69 |
70 | include
71 | #interface
72 |
73 |
74 | include
75 | #enum
76 |
77 |
78 | include
79 | #type
80 |
81 |
82 | include
83 | #function-exist
84 |
85 |
86 | include
87 | #generic
88 |
89 |
90 | include
91 | #escaped-fix
92 |
93 |
94 | include
95 | #builtin-fix
96 |
97 |
98 | include
99 | #brackets
100 |
101 |
102 | include
103 | #flag-decl
104 |
105 |
106 | include
107 | #include-decl
108 |
109 |
110 | include
111 | #import-decl
112 |
113 |
114 | include
115 | #module-decl
116 |
117 |
118 | include
119 | #attributes
120 |
121 |
122 | include
123 | #assignment
124 |
125 |
126 | include
127 | #module-func-call
128 |
129 |
130 | repository
131 |
132 | as-is
133 |
134 | begin
135 | \s+(as|is)\s+
136 | beginCaptures
137 |
138 | 1
139 |
140 | name
141 | keyword.$1.v
142 |
143 |
144 | end
145 | ([\w.]*)
146 | endCaptures
147 |
148 | 1
149 |
150 | name
151 | entity.name.alias.v
152 |
153 |
154 |
155 | assignment
156 |
157 | captures
158 |
159 | 1
160 |
161 | name
162 | variable.assignment.other.v
163 |
164 |
165 | match
166 | ([\w.]+)\s*((?:\:\=|\+\=|\-\=|\*\=|\/\=|\%\=|\&\=|\|\=|\^\=))\s*(?=.+)
167 | name
168 | meta.definition.variable.v
169 |
170 | attributes
171 |
172 | captures
173 |
174 | 1
175 |
176 | name
177 | meta.function.attribute.v
178 |
179 | 2
180 |
181 | name
182 | punctuation.definition.begin.bracket.square.v
183 |
184 | 3
185 |
186 | name
187 | storage.modifier.attribute.v
188 |
189 | 4
190 |
191 | name
192 | punctuation.definition.end.bracket.square.v
193 |
194 |
195 | match
196 | ^\s*((\[)(deprecated|unsafe_fn|typedef|live|inline|flag)(\]))
197 | name
198 | meta.definition.attribute.v
199 |
200 | brackets
201 |
202 | patterns
203 |
204 |
205 | begin
206 | {
207 | beginCaptures
208 |
209 | 0
210 |
211 | name
212 | punctuation.definition.bracket.curly.begin.v
213 |
214 |
215 | end
216 | }
217 | endCaptures
218 |
219 | 0
220 |
221 | name
222 | punctuation.definition.bracket.curly.end.v
223 |
224 |
225 | patterns
226 |
227 |
228 | include
229 | $self
230 |
231 |
232 |
233 |
234 | begin
235 | \(
236 | beginCaptures
237 |
238 | 0
239 |
240 | name
241 | punctuation.definition.bracket.round.begin.v
242 |
243 |
244 | end
245 | \)
246 | endCaptures
247 |
248 | 0
249 |
250 | name
251 | punctuation.definition.bracket.round.end.v
252 |
253 |
254 | patterns
255 |
256 |
257 | include
258 | $self
259 |
260 |
261 |
262 |
263 | begin
264 | \[
265 | beginCaptures
266 |
267 | 0
268 |
269 | name
270 | punctuation.definition.bracket.square.begin.v
271 |
272 |
273 | end
274 | \]
275 | endCaptures
276 |
277 | 0
278 |
279 | name
280 | punctuation.definition.bracket.square.end.v
281 |
282 |
283 | patterns
284 |
285 |
286 | include
287 | $self
288 |
289 |
290 |
291 |
292 |
293 | builtin-fix
294 |
295 | patterns
296 |
297 |
298 | patterns
299 |
300 |
301 | match
302 | (const)(?=\s*\()
303 | name
304 | storage.modifier.v
305 |
306 |
307 | match
308 | \b(fn|type|enum|struct|interface|map|assert|sizeof)\b(?=\s*\()
309 | name
310 | keyword.$1.v
311 |
312 |
313 |
314 |
315 | patterns
316 |
317 |
318 | match
319 | (\$if|\$else)(?=\s*\()
320 | name
321 | keyword.control.v
322 |
323 |
324 | match
325 | \b(in|is|or|break|continue|default|unsafe|match|if|else|for|go|goto|defer|return)\b(?=\s*\()
326 | name
327 | keyword.control.v
328 |
329 |
330 |
331 |
332 | patterns
333 |
334 |
335 | captures
336 |
337 | 1
338 |
339 | name
340 | storage.type.numeric.v
341 |
342 |
343 | match
344 | (i?(?:8|16|nt|64|128)|u?(?:16|32|64|128)|f?(?:32|64))(?=\s*\()
345 | name
346 | meta.expr.numeric.cast.v
347 |
348 |
349 | captures
350 |
351 | 1
352 |
353 | name
354 | storage.type.$1.v
355 |
356 |
357 | match
358 | (bool|byte|byteptr|charptr|voidptr|string|ustring|rune|none)(?=\s*\()
359 | name
360 | meta.expr.bool.cast.v
361 |
362 |
363 |
364 |
365 |
366 | comments
367 |
368 | patterns
369 |
370 |
371 | begin
372 | /\*
373 | beginCaptures
374 |
375 | 0
376 |
377 | name
378 | punctuation.definition.comment.begin.v
379 |
380 |
381 | end
382 | \*/
383 | endCaptures
384 |
385 | 0
386 |
387 | name
388 | punctuation.definition.comment.end.v
389 |
390 |
391 | name
392 | comment.block.documentation.v
393 | patterns
394 |
395 |
396 | include
397 | #comments
398 |
399 |
400 |
401 |
402 | begin
403 | //
404 | beginCaptures
405 |
406 | 0
407 |
408 | name
409 | punctuation.definition.comment.begin.v
410 |
411 |
412 | end
413 | $
414 | name
415 | comment.line.double-slash.v
416 |
417 |
418 |
419 | constants
420 |
421 | match
422 | \b(true|false)\b
423 | name
424 | constant.language.v
425 |
426 | enum
427 |
428 | captures
429 |
430 | 1
431 |
432 | name
433 | storage.modifier.$1.v
434 |
435 | 2
436 |
437 | name
438 | storage.type.enum.v
439 |
440 | 3
441 |
442 | name
443 | entity.name.enum.v
444 |
445 |
446 | match
447 | ^\s*(?:(pub)?\s+)?(enum)\s+(?:\w+\.)?(\w*)
448 | name
449 | meta.definition.enum.v
450 |
451 | escaped-fix
452 |
453 | captures
454 |
455 | 0
456 |
457 | name
458 | keyword.other.escaped.v
459 |
460 |
461 | match
462 | ((?:@)(?:mut|var|pub|fn|unsafe|module|import|as|const|map|assert|sizeof|type|struct|interface|enum|in|is|or|match|if|else|for|go|goto|defer|return|i?(?:8|16|nt|64|128)|u?(?:16|32|64|128)|f?(?:32|64)|bool|byte|byteptr|charptr|voidptr|string|ustring|rune|none))
463 | name
464 | meta.escaped.keyword.v
465 |
466 | flag-decl
467 |
468 | begin
469 | ^\s*(#flag)
470 | beginCaptures
471 |
472 | 1
473 |
474 | name
475 | keyword.flag.v
476 |
477 |
478 | end
479 | \s+(.*?)$
480 | endCaptures
481 |
482 | 1
483 |
484 | name
485 | string.quoted.single.v
486 |
487 |
488 | name
489 | meta.flag.v
490 |
491 | function-exist
492 |
493 | captures
494 |
495 | 0
496 |
497 | name
498 | meta.function.call.v
499 |
500 |
501 | match
502 | (\w+)((?<=[\w\s+])(\<)(\w+)(\>))?(?=\s*\()
503 | name
504 | meta.support.function.v
505 |
506 | generic
507 |
508 | patterns
509 |
510 |
511 | captures
512 |
513 | 1
514 |
515 | name
516 | punctuation.definition.bracket.angle.begin.v
517 |
518 | 3
519 |
520 | name
521 | punctuation.definition.bracket.angle.end.v
522 |
523 |
524 | match
525 | (?<=[\w\s+])(\<)(\w+)(\>)
526 | name
527 | meta.definition.generic.v
528 |
529 |
530 |
531 | import-decl
532 |
533 | begin
534 | ^\s*(import)\s+
535 | beginCaptures
536 |
537 | 1
538 |
539 | name
540 | keyword.import.v
541 |
542 |
543 | end
544 | ([\w.]+)
545 | endCaptures
546 |
547 | 1
548 |
549 | name
550 | entity.name.import.v
551 |
552 |
553 | name
554 | meta.import.v
555 |
556 | include-decl
557 |
558 | begin
559 | ^\s*(#include)
560 | beginCaptures
561 |
562 | 1
563 |
564 | name
565 | keyword.include.v
566 |
567 |
568 | end
569 | \s+(([\<"])\s*(.*)([\>"]))
570 | endCaptures
571 |
572 | 1
573 |
574 | name
575 | string.quoted.double.v
576 |
577 |
578 | name
579 | meta.include.v
580 |
581 | interface
582 |
583 | captures
584 |
585 | 1
586 |
587 | name
588 | storage.modifier.$1.v
589 |
590 | 2
591 |
592 | name
593 | keyword.interface.v
594 |
595 |
596 | match
597 | ^\s*(?:(pub)?\s+)?(interface)\s+(\w*)
598 | name
599 | meta.definition.interface.v
600 |
601 | keywords
602 |
603 | patterns
604 |
605 |
606 | match
607 | (\$if|\$else)
608 | name
609 | keyword.control.v
610 |
611 |
612 | match
613 | \b(in|is|or|break|continue|default|unsafe|match|if|else|for|go|goto|defer|return)\b
614 | name
615 | keyword.control.v
616 |
617 |
618 | match
619 | \b(fn|type|enum|struct|interface|map|assert|sizeof)\b
620 | name
621 | keyword.$1.v
622 |
623 |
624 |
625 | module-decl
626 |
627 | begin
628 | ^\s*(module)\s+
629 | beginCaptures
630 |
631 | 1
632 |
633 | name
634 | keyword.module.v
635 |
636 |
637 | end
638 | ([\w.]+)
639 | endCaptures
640 |
641 | 1
642 |
643 | name
644 | entity.name.module.v
645 |
646 |
647 | name
648 | meta.module.v
649 |
650 | module-func-call
651 |
652 | captures
653 |
654 | 1
655 |
656 | name
657 | constant.numeric.integer.v
658 |
659 |
660 | match
661 | \s*(\w+)\.\w+
662 | name
663 | module.function.call.v
664 |
665 | numbers
666 |
667 | patterns
668 |
669 |
670 | match
671 | (?:(?:[-]?)(?:[0-9e]*)(?:[.]){1}(?:[0-9]+))
672 | name
673 | constant.numeric.float.v
674 |
675 |
676 | match
677 | \b(?:0[xX])(?:[0-9a-fA-F]+)
678 | name
679 | constant.numeric.hex.v
680 |
681 |
682 | match
683 | \b(?:[-]?)(?:[0-9]+)
684 | name
685 | constant.numeric.integer.v
686 |
687 |
688 |
689 | operators
690 |
691 | patterns
692 |
693 |
694 | match
695 | (\=\=|\!\=|\>|\<|\>\=|\<\=)
696 | name
697 | keyword.operator.relation.v
698 |
699 |
700 | match
701 | (\+|\-|\*|\/|\%|\+\+|\-\-)
702 | name
703 | keyword.operator.arithmethic.v
704 |
705 |
706 | match
707 | (\:\=|\=|\+\=|\-\=|\*\=|\/\=|\%\=|\&\=|\|\=|\^\=|\&\&\=|\|\|\=|\>\>\=|\<\<\=)
708 | name
709 | keyword.operator.assignment.v
710 |
711 |
712 | match
713 | (\&|\||\^|<(?!<)|>(?!>))
714 | name
715 | keyword.operator.bitwise.v
716 |
717 |
718 | match
719 | (\&\&|\|\||\!)
720 | name
721 | keyword.operator.logical.v
722 |
723 |
724 |
725 | punctuation
726 |
727 | patterns
728 |
729 |
730 | match
731 | \.
732 | name
733 | punctuation.delimiter.period.dot.v
734 |
735 |
736 | match
737 | ,
738 | name
739 | punctuation.delimiter.comma.v
740 |
741 |
742 | match
743 | :
744 | name
745 | punctuation.separator.key-value.colon.v
746 |
747 |
748 | match
749 | ;
750 | name
751 | punctuation.definition.other.semicolon.v
752 |
753 |
754 | match
755 | \?
756 | name
757 | punctuation.definition.other.questionmark.v
758 |
759 |
760 |
761 | storage
762 |
763 | match
764 | \b(const|mut|var|pub)\b
765 | name
766 | storage.modifier.v
767 |
768 | string-escaped-char
769 |
770 | patterns
771 |
772 |
773 | match
774 | \\([0-7]{3}|[\$abfnrtv\\'"]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})
775 | name
776 | constant.character.escape.v
777 |
778 |
779 | match
780 | \\[^0-7\$xuUabfnrtv\'"]
781 | name
782 | invalid.illegal.unknown-escape.v
783 |
784 |
785 |
786 | string-placeholder
787 |
788 | match
789 | %(\[\d+\])?([\+#\-0\x20]{,2}((\d+|\*)?(\.?(\d+|\*|(\[\d+\])\*?)?(\[\d+\])?)?))?[vT%tbcdoqxXUbeEfFgGsp]
790 | name
791 | constant.other.placeholder.v
792 |
793 | strings
794 |
795 | patterns
796 |
797 |
798 | begin
799 | `
800 | beginCaptures
801 |
802 | 0
803 |
804 | name
805 | punctuation.definition.string.raw.begin.v
806 |
807 |
808 | end
809 | `
810 | endCaptures
811 |
812 | 0
813 |
814 | name
815 | punctuation.definition.string.raw.end.v
816 |
817 |
818 | name
819 | string.quoted.raw.v
820 | patterns
821 |
822 |
823 | include
824 | #string-escaped-char
825 |
826 |
827 | include
828 | #string-interpolation
829 |
830 |
831 | include
832 | #string-placeholder
833 |
834 |
835 |
836 |
837 | begin
838 | '
839 | beginCaptures
840 |
841 | 0
842 |
843 | name
844 | punctuation.definition.string.single.begin.v
845 |
846 |
847 | end
848 | '
849 | endCaptures
850 |
851 | 0
852 |
853 | name
854 | punctuation.definition.string.single.end.v
855 |
856 |
857 | name
858 | string.quoted.single.v
859 | patterns
860 |
861 |
862 | include
863 | #string-escaped-char
864 |
865 |
866 | include
867 | #string-interpolation
868 |
869 |
870 | include
871 | #string-placeholder
872 |
873 |
874 |
875 |
876 | begin
877 | "
878 | beginCaptures
879 |
880 | 0
881 |
882 | name
883 | punctuation.definition.string.double.begin.v
884 |
885 |
886 | end
887 | "
888 | endCaptures
889 |
890 | 0
891 |
892 | name
893 | punctuation.definition.string.double.end.v
894 |
895 |
896 | name
897 | string.quoted.double.v
898 | patterns
899 |
900 |
901 | include
902 | #string-escaped-char
903 |
904 |
905 | include
906 | #string-interpolation
907 |
908 |
909 | include
910 | #string-placeholder
911 |
912 |
913 |
914 |
915 |
916 | struct
917 |
918 | patterns
919 |
920 |
921 | begin
922 | ^\s*(?:(mut|var|pub(?:\s+mut|var)?|__global)\s+)?(struct)\s+([\w.]+)\s*({)
923 | beginCaptures
924 |
925 | 1
926 |
927 | name
928 | storage.modifier.$1.v
929 |
930 | 2
931 |
932 | name
933 | storage.type.struct.v
934 |
935 | 3
936 |
937 | name
938 | entity.name.struct.v
939 |
940 | 4
941 |
942 | name
943 | punctuation.definition.bracket.curly.begin.v
944 |
945 |
946 | end
947 | \s*(})
948 | endCaptures
949 |
950 | 1
951 |
952 | name
953 | punctuation.definition.bracket.curly.end.v
954 |
955 |
956 | name
957 | meta.definition.struct.v
958 | patterns
959 |
960 |
961 | include
962 | #struct-access-modifier
963 |
964 |
965 | captures
966 |
967 | 1
968 |
969 | name
970 | variable.other.property.v
971 |
972 | 3
973 |
974 | name
975 | keyword.operator.assignment.v
976 |
977 |
978 | match
979 | \b(\w+)\s+([\w\[\]\*&.]+)(?:\s*(=)\s*((?:.(?=$|//|/\*))*+))?
980 |
981 |
982 | include
983 | #types
984 |
985 |
986 | include
987 | $self
988 |
989 |
990 |
991 |
992 | captures
993 |
994 | 1
995 |
996 | name
997 | storage.modifier.$1.v
998 |
999 | 2
1000 |
1001 | name
1002 | storage.type.struct.v
1003 |
1004 | 3
1005 |
1006 | name
1007 | entity.name.struct.v
1008 |
1009 |
1010 | match
1011 | ^\s*(?:(mut|var|pub(?:\s+mut|var)?|__global)\s+)?(struct)(?:\s+([\w.]+))?
1012 | name
1013 | meta.definition.struct.v
1014 |
1015 |
1016 |
1017 | struct-access-modifier
1018 |
1019 | captures
1020 |
1021 | 1
1022 |
1023 | name
1024 | storage.modifier.$1.v
1025 |
1026 | 2
1027 |
1028 | name
1029 | punctuation.separator.struct.key-value.v
1030 |
1031 |
1032 | match
1033 | (?<=\s|^)(mut|var|pub(?:\s+mut|var)?|__global)(:|\b)
1034 |
1035 | type
1036 |
1037 | captures
1038 |
1039 | 1
1040 |
1041 | name
1042 | storage.modifier.$1.v
1043 |
1044 | 2
1045 |
1046 | name
1047 | storage.type.type.v
1048 |
1049 |
1050 | match
1051 | ^\s*(?:(pub)?\s+)?(type)\s+(\w*)\s+(?:\w+\.+)?(\w*)
1052 | name
1053 | meta.definition.type.v
1054 |
1055 | types
1056 |
1057 | patterns
1058 |
1059 |
1060 | match
1061 | \b(i(8|16|nt|64|128)|u(8|16|32|64|128)|f(32|64))\b
1062 | name
1063 | storage.type.numeric.v
1064 |
1065 |
1066 | match
1067 | \b(bool|byte|byteptr|charptr|voidptr|string|ustring|rune|none)\b
1068 | name
1069 | storage.type.$1.v
1070 |
1071 |
1072 |
1073 |
1074 | scopeName
1075 | source.v
1076 | uuid
1077 | ca9f2cc0-a834-40aa-8987-3ef92dbc7517
1078 |
1079 |
1080 |
--------------------------------------------------------------------------------