Skip to content

Commit 493ec30

Browse files
committed
fix: literals, fakeplayers, properties
- literals with suffixes (b, B, l, L) now highlight properly - literals inside properties (specifically `true`/`false`) highlight better - resource-names within properties highlight better - this causes false-positives via `minecraft:block{key:value}` to highlight incorrectly - added `-`, `.` as a valid special fakeplayer character - these only trigger if it looks like a fakeplayer - improved some testing - fixed sublime support (hopefully) - adjusted some scope names to match lang-mcf
1 parent c5bfa05 commit 493ec30

6 files changed

+212
-118
lines changed

README.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@ The aim of this syntax definition is to provide a general, feature complete lang
2121
## TODOs
2222

2323
- [x] Add explicit macro support
24-
- [ ] Fix issues with nbt and other suffixes on numbrs
25-
- [ ] Fix issues on resource names versus keywords
26-
- Specifically when using dotted names
24+
- [x] Fix issues with nbt and other suffixes on numbrs
25+
- [x] Fix issues on resource names versus keywords
2726
- [ ] Add tests for Bedrock
2827
- [ ] (VSCode & Sublime) Add jsonschema file for `pack.mcmeta`
29-
- [ ] Compare w/ `language-mcfunction` to synchronize scope names
30-
- It'll never reach 1:1, but we can get to 70-80%
28+
- [-] Compare w/ `language-mcfunction` to synchronize scope names
29+
- Likely won't get better than this tbh, will need feedback
3130

3231
## Installing
3332

@@ -43,7 +42,7 @@ It is recommended you use [Package Control](https://packagecontrol.io/) to manag
4342
2. Run the `Package Control: Add Repository` [command](https://packagecontrol.io/docs/usage) and enter `https://github.com/MinecraftCommands/syntax-mcfunction.git` to add the repository as a package.
4443
3. Run the `Package Control: Install Package` and search for `syntax-mcfunction` to install it as you would a normal package.
4544

46-
<details><summary> If you already had language-mcfunction </summary>
45+
<details><summary> If you already had <code>language-mcfunction</code> </summary>
4746

4847
> **Note**
4948
> You might want to remove Arc's language-mcfunction if you have it installed. You can do that via `Package Control: Remove Repository` and selecting https://github.com/Arcensoth/language-mcfunction then `Package Control: Remove Package` and selecting `language-mcfunction` from 2021.

mcfunction.tmLanguage.plist mcfunction.tmLanguage

+79-37
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
<key>fileTypes</key>
66
<array>
77
<string>mcfunction</string>
8+
<string>bolt</string>
89
</array>
910
<key>name</key>
10-
<string>Mcfunction</string>
11+
<string>Syntax Mcfunction</string>
1112
<key>patterns</key>
1213
<array>
1314
<dict>
@@ -245,11 +246,11 @@
245246
<key>0</key>
246247
<dict>
247248
<key>name</key>
248-
<string>keyword.other.psuedo.mcfunction</string>
249+
<string>constant.numeric.boolean.mcfunction</string>
249250
</dict>
250251
</dict>
251252
<key>match</key>
252-
<string>(true|false)</string>
253+
<string>(true|false|True|False)</string>
253254
<key>name</key>
254255
<string>meta.literals</string>
255256
</dict>
@@ -259,25 +260,25 @@
259260
<key>0</key>
260261
<dict>
261262
<key>name</key>
262-
<string>entity.name.class.mcfunction</string>
263+
<string>variable.uuid.mcfunction</string>
263264
</dict>
264265
</dict>
265266
<key>match</key>
266-
<string>[A-Za-z_]+</string>
267+
<string>\b[0-9a-fA-F]+(?:-[0-9a-fA-F]+){4}\b</string>
267268
<key>name</key>
268-
<string>meta.literals</string>
269+
<string>meta.names</string>
269270
</dict>
270271
<dict>
271272
<key>captures</key>
272273
<dict>
273274
<key>0</key>
274275
<dict>
275276
<key>name</key>
276-
<string>constant.numeric.byte.mcfunction</string>
277+
<string>constant.numeric.float.mcfunction</string>
277278
</dict>
278279
</dict>
279280
<key>match</key>
280-
<string>[0-9]b</string>
281+
<string>[+-]?\d*\.?\d+([eE]?[+-]?\d+)?[df]?\b</string>
281282
<key>name</key>
282283
<string>meta.literals</string>
283284
</dict>
@@ -287,11 +288,11 @@
287288
<key>0</key>
288289
<dict>
289290
<key>name</key>
290-
<string>constant.numeric.float.mcfunction</string>
291+
<string>constant.numeric.integer.mcfunction</string>
291292
</dict>
292293
</dict>
293294
<key>match</key>
294-
<string>[+-]?\d*\.?\d+([eE]?[+-]?\d+)?[df]?\b</string>
295+
<string>[+-]?\d+(b|B|L|l)\b</string>
295296
<key>name</key>
296297
<string>meta.literals</string>
297298
</dict>
@@ -461,7 +462,7 @@
461462
</dict>
462463
</dict>
463464
<key>match</key>
464-
<string>(\$\()([A-Za-z0-9_]+)(\))</string>
465+
<string>(\$\()([A-Za-z0-9_]*)(\))</string>
465466
<key>name</key>
466467
<string>meta.macro-name</string>
467468
</dict>
@@ -488,7 +489,7 @@
488489
<key>match</key>
489490
<string>^(\s*)([a-z_]+)(?=\s)</string>
490491
<key>name</key>
491-
<string>meta.names.mcfunction</string>
492+
<string>meta.names</string>
492493
</dict>
493494
<dict>
494495
<key>captures</key>
@@ -504,41 +505,42 @@
504505
<string>markup.italic.mcfunction</string>
505506
</dict>
506507
<key>3</key>
508+
<dict>
509+
<key>name</key>
510+
<string>whitespace.mcfunction</string>
511+
</dict>
512+
<key>4</key>
507513
<dict>
508514
<key>name</key>
509515
<string>keyword.control.flow.mcfunction</string>
510516
</dict>
511517
</dict>
512518
<key>match</key>
513-
<string>^(\s*)(\$)([a-z_]*)</string>
519+
<string>^(\s*)(\$)( ?)([a-z_]*)</string>
514520
<key>name</key>
515-
<string>meta.names.mcfunction</string>
521+
<string>meta.names</string>
516522
</dict>
517523
<dict>
518524
<key>captures</key>
519525
<dict>
520-
<key>0</key>
526+
<key>1</key>
521527
<dict>
522528
<key>name</key>
523-
<string>keyboard.control.flow.mcfunction</string>
529+
<string>entity.name.mcfunction</string>
524530
</dict>
525-
</dict>
526-
<key>match</key>
527-
<string>(?&lt;=run)\s+[a-z_]+(?=\s)</string>
528-
<key>name</key>
529-
<string>meta.names.mcfunction</string>
530-
</dict>
531-
<dict>
532-
<key>captures</key>
533-
<dict>
534-
<key>0</key>
531+
<key>2</key>
535532
<dict>
536533
<key>name</key>
537-
<string>variable.uuid.mcfunction</string>
534+
<string>whitespace.mcfunction</string>
535+
</dict>
536+
<key>3</key>
537+
<dict>
538+
<key>name</key>
539+
<string>keyword.control.flow.mcfunction</string>
538540
</dict>
539541
</dict>
540542
<key>match</key>
541-
<string>\b[0-9a-fA-F]+(?:-[0-9a-fA-F]+){4}\b</string>
543+
<string>(run)(\s+)([a-z_]+)</string>
542544
<key>name</key>
543545
<string>meta.names</string>
544546
</dict>
@@ -588,7 +590,7 @@
588590
</dict>
589591
</dict>
590592
<key>match</key>
591-
<string>[#%$][A-Za-z0-9_.#%$]+</string>
593+
<string>([#%$]|((?&lt;=\s)\.))[A-Za-z0-9_.#%$\-]+</string>
592594
<key>name</key>
593595
<string>meta.names</string>
594596
</dict>
@@ -608,7 +610,7 @@
608610
</dict>
609611
</dict>
610612
<key>match</key>
611-
<string>[\-~%^?!+*&lt;&gt;\\/|&amp;=.:,]</string>
613+
<string>[\-~%^?!+*&lt;&gt;\\/|&amp;=.:,;]</string>
612614
<key>name</key>
613615
<string>meta.operators</string>
614616
</dict>
@@ -637,6 +639,14 @@
637639
<string>meta.property.curly</string>
638640
<key>patterns</key>
639641
<array>
642+
<dict>
643+
<key>include</key>
644+
<string>#resource-name</string>
645+
</dict>
646+
<dict>
647+
<key>include</key>
648+
<string>#literals</string>
649+
</dict>
640650
<dict>
641651
<key>include</key>
642652
<string>#property_key</string>
@@ -665,7 +675,7 @@
665675
<key>0</key>
666676
<dict>
667677
<key>name</key>
668-
<string>punctuation.mcfunction</string>
678+
<string>variable.other.mcfunction</string>
669679
</dict>
670680
</dict>
671681
<key>end</key>
@@ -674,6 +684,14 @@
674684
<string>meta.property.square</string>
675685
<key>patterns</key>
676686
<array>
687+
<dict>
688+
<key>include</key>
689+
<string>#resource-name</string>
690+
</dict>
691+
<dict>
692+
<key>include</key>
693+
<string>#literals</string>
694+
</dict>
677695
<dict>
678696
<key>include</key>
679697
<string>#property_key</string>
@@ -715,6 +733,10 @@
715733
<key>include</key>
716734
<string>#resource-name</string>
717735
</dict>
736+
<dict>
737+
<key>include</key>
738+
<string>#literals</string>
739+
</dict>
718740
<dict>
719741
<key>include</key>
720742
<string>#property_key</string>
@@ -815,10 +837,6 @@
815837
<key>name</key>
816838
<string>meta.property_value</string>
817839
</dict>
818-
<dict>
819-
<key>include</key>
820-
<string>#literals</string>
821-
</dict>
822840
</array>
823841
</dict>
824842
<key>resource-name</key>
@@ -859,6 +877,10 @@
859877
<dict>
860878
<key>patterns</key>
861879
<array>
880+
<dict>
881+
<key>include</key>
882+
<string>#literals</string>
883+
</dict>
862884
<dict>
863885
<key>include</key>
864886
<string>#names</string>
@@ -869,7 +891,7 @@
869891
</dict>
870892
<dict>
871893
<key>include</key>
872-
<string>#literals</string>
894+
<string>#subcommands</string>
873895
</dict>
874896
<dict>
875897
<key>include</key>
@@ -899,12 +921,32 @@
899921
</dict>
900922
</dict>
901923
<key>match</key>
902-
<string>@[a-z]</string>
924+
<string>@[a-z]+</string>
903925
<key>name</key>
904926
<string>meta.selectors</string>
905927
</dict>
906928
</array>
907929
</dict>
930+
<key>subcommands</key>
931+
<dict>
932+
<key>patterns</key>
933+
<array>
934+
<dict>
935+
<key>captures</key>
936+
<dict>
937+
<key>0</key>
938+
<dict>
939+
<key>name</key>
940+
<string>entity.name.class.mcfunction</string>
941+
</dict>
942+
</dict>
943+
<key>match</key>
944+
<string>[A-Za-z_]+</string>
945+
<key>name</key>
946+
<string>meta.literals</string>
947+
</dict>
948+
</array>
949+
</dict>
908950
</dict>
909951
<key>scopeName</key>
910952
<string>source.mcfunction</string>

0 commit comments

Comments
 (0)