Skip to content

Commit 873fd49

Browse files
Add scope keyword.control.end to all 'end' keywords. Optimization of complex regexes. Add scopes for BEGIN and END keywords.
1 parent b946741 commit 873fd49

File tree

1 file changed

+109
-30
lines changed

1 file changed

+109
-30
lines changed

Syntaxes/Ruby.plist

Lines changed: 109 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,15 @@
116116
</dict>
117117
</dict>
118118
<key>end</key>
119-
<string>(?&lt;!\.|::)\bend\b(?![?!])</string>
119+
<string>(?&lt;!\.|::)\b((end))\b(?![?!])</string>
120120
<key>endCaptures</key>
121121
<dict>
122-
<key>0</key>
122+
<key>1</key>
123+
<dict>
124+
<key>name</key>
125+
<string>keyword.control.end.ruby</string>
126+
</dict>
127+
<key>2</key>
123128
<dict>
124129
<key>name</key>
125130
<string>keyword.control.class.end.ruby</string>
@@ -228,10 +233,15 @@
228233
</dict>
229234
</dict>
230235
<key>end</key>
231-
<string>(?&lt;!\.|::)\bend\b(?![?!])</string>
236+
<string>(?&lt;!\.|::)\b((end))\b(?![?!])</string>
232237
<key>endCaptures</key>
233238
<dict>
234-
<key>0</key>
239+
<key>1</key>
240+
<dict>
241+
<key>name</key>
242+
<string>keyword.control.end.ruby</string>
243+
</dict>
244+
<key>2</key>
235245
<dict>
236246
<key>name</key>
237247
<string>keyword.control.module.end.ruby</string>
@@ -341,10 +351,15 @@
341351
</dict>
342352
</dict>
343353
<key>end</key>
344-
<string>(?&lt;!\.|::)\bend\b(?![?!])</string>
354+
<string>(?&lt;!\.|::)\b((end))\b(?![?!])</string>
345355
<key>endCaptures</key>
346356
<dict>
347-
<key>0</key>
357+
<key>1</key>
358+
<dict>
359+
<key>name</key>
360+
<string>keyword.control.end.ruby</string>
361+
</dict>
362+
<key>2</key>
348363
<dict>
349364
<key>name</key>
350365
<string>keyword.control.for.end.ruby</string>
@@ -421,10 +436,15 @@
421436
</dict>
422437
</dict>
423438
<key>end</key>
424-
<string>(?&lt;!\.|::)\bend\b(?![?!])</string>
439+
<string>(?&lt;!\.|::)\b((end))\b(?![?!])</string>
425440
<key>endCaptures</key>
426441
<dict>
427-
<key>0</key>
442+
<key>1</key>
443+
<dict>
444+
<key>name</key>
445+
<string>keyword.control.end.ruby</string>
446+
</dict>
447+
<key>2</key>
428448
<dict>
429449
<key>name</key>
430450
<string>keyword.control.do.end.ruby</string>
@@ -452,10 +472,15 @@
452472
</dict>
453473
</dict>
454474
<key>end</key>
455-
<string>(?&lt;!\.|::)\bend\b(?![?!])</string>
475+
<string>(?&lt;!\.|::)\b((end))\b(?![?!])</string>
456476
<key>endCaptures</key>
457477
<dict>
458-
<key>0</key>
478+
<key>1</key>
479+
<dict>
480+
<key>name</key>
481+
<string>keyword.control.end.ruby</string>
482+
</dict>
483+
<key>2</key>
459484
<dict>
460485
<key>name</key>
461486
<string>keyword.control.begin.end.ruby</string>
@@ -483,10 +508,15 @@
483508
</dict>
484509
</dict>
485510
<key>end</key>
486-
<string>(?&lt;!\.|::)\bend\b(?![?!])</string>
511+
<string>(?&lt;!\.|::)\b((end))\b(?![?!])</string>
487512
<key>endCaptures</key>
488513
<dict>
489-
<key>0</key>
514+
<key>1</key>
515+
<dict>
516+
<key>name</key>
517+
<string>keyword.control.end.ruby</string>
518+
</dict>
519+
<key>2</key>
490520
<dict>
491521
<key>name</key>
492522
<string>keyword.control.conditional.case.end.ruby</string>
@@ -615,6 +645,7 @@
615645
</dict>
616646
<key>match</key>
617647
<string>(?x)
648+
(?=if\b|unless\b)
618649
(?&lt;=[}\])\w?!"'`])
619650
(?&lt;!\Wif|^if| # \WX|^X is equivalent to \bX
620651
\Wunless|^unless| # this is workaround for code editors which doesn't support onigomo
@@ -636,6 +667,7 @@
636667
<dict>
637668
<key>begin</key>
638669
<string>(?x)
670+
(?=if\b)
639671
(?&lt;!::)
640672
(?&lt;=&lt;|&amp;|\||=|&gt;|~|\^|[+\-*/%]|\.{2}|\.{3}|^|;|:|\[|\(|\{|,|
641673
\Wif|^if| # \WX|^X is equivalent to \bX
@@ -663,10 +695,15 @@
663695
</dict>
664696
</dict>
665697
<key>end</key>
666-
<string>(?&lt;!\.|::)\bend\b(?![?!])</string>
698+
<string>(?&lt;!\.|::)\b((end))\b(?![?!])</string>
667699
<key>endCaptures</key>
668700
<dict>
669-
<key>0</key>
701+
<key>1</key>
702+
<dict>
703+
<key>name</key>
704+
<string>keyword.control.end.ruby</string>
705+
</dict>
706+
<key>2</key>
670707
<dict>
671708
<key>name</key>
672709
<string>keyword.control.conditional.if.end.ruby</string>
@@ -685,6 +722,7 @@
685722
<dict>
686723
<key>begin</key>
687724
<string>(?x)
725+
(?=unless\b)
688726
(?&lt;!::)
689727
(?&lt;=&lt;|&amp;|\||=|&gt;|~|\^|[+\-*/%]|\.{2}|\.{3}|^|;|:|\[|\(|\{|,|
690728
\Wif|^if| # \WX|^X is equivalent to \bX
@@ -712,10 +750,15 @@
712750
</dict>
713751
</dict>
714752
<key>end</key>
715-
<string>(?&lt;!\.|::)\bend\b(?![?!])</string>
753+
<string>(?&lt;!\.|::)\b((end))\b(?![?!])</string>
716754
<key>endCaptures</key>
717755
<dict>
718-
<key>0</key>
756+
<key>1</key>
757+
<dict>
758+
<key>name</key>
759+
<string>keyword.control.end.ruby</string>
760+
</dict>
761+
<key>2</key>
719762
<dict>
720763
<key>name</key>
721764
<string>keyword.control.conditional.unless.end.ruby</string>
@@ -747,6 +790,7 @@
747790
</dict>
748791
<key>match</key>
749792
<string>(?x)
793+
(?=while\b|until\b)
750794
(?&lt;=[}\])\w?!"'`])
751795
(?&lt;!\Wif|^if| # \WX|^X is equivalent to \bX
752796
\Wunless|^unless| # this is workaround for code editors which doesn't support onigomo
@@ -768,6 +812,7 @@
768812
<dict>
769813
<key>begin</key>
770814
<string>(?x)
815+
(?=while\b)
771816
(?&lt;!::)
772817
(?&lt;=&lt;|&amp;|\||=|&gt;|~|\^|[+\-*/%]|\.{2}|\.{3}|^|;|:|\[|\(|\{|,|
773818
\Wif|^if| # \WX|^X is equivalent to \bX
@@ -795,10 +840,15 @@
795840
</dict>
796841
</dict>
797842
<key>end</key>
798-
<string>(?&lt;!\.|::)\bend\b(?![?!])</string>
843+
<string>(?&lt;!\.|::)\b((end))\b(?![?!])</string>
799844
<key>endCaptures</key>
800845
<dict>
801-
<key>0</key>
846+
<key>1</key>
847+
<dict>
848+
<key>name</key>
849+
<string>keyword.control.end.ruby</string>
850+
</dict>
851+
<key>2</key>
802852
<dict>
803853
<key>name</key>
804854
<string>keyword.control.while.end.ruby</string>
@@ -838,6 +888,7 @@
838888
<dict>
839889
<key>begin</key>
840890
<string>(?x)
891+
(?=until\b)
841892
(?&lt;!::)
842893
(?&lt;=&lt;|&amp;|\||=|&gt;|~|\^|[+\-*/%]|\.{2}|\.{3}|^|;|:|\[|\(|\{|,|
843894
\Wif|^if| # \WX|^X is equivalent to \bX
@@ -865,10 +916,15 @@
865916
</dict>
866917
</dict>
867918
<key>end</key>
868-
<string>(?&lt;!\.|::)\bend\b(?![?!])</string>
919+
<string>(?&lt;!\.|::)\b((end))\b(?![?!])</string>
869920
<key>endCaptures</key>
870921
<dict>
871-
<key>0</key>
922+
<key>1</key>
923+
<dict>
924+
<key>name</key>
925+
<string>keyword.control.end.ruby</string>
926+
</dict>
927+
<key>2</key>
872928
<dict>
873929
<key>name</key>
874930
<string>keyword.control.until.end.ruby</string>
@@ -923,13 +979,21 @@
923979
<key>name</key>
924980
<string>keyword.control.conditional.$1.ruby</string>
925981
</dict>
982+
<dict><key>comment</key>
983+
<string>
984+
All structures that are closed with keyword 'end' already defined higher.
985+
This rule is made to match freestanding 'end'.
986+
</string>
987+
<key>match</key>
988+
<string>(?&lt;!\.|::)\bend\b(?![?!])</string>
989+
<key>name</key>
990+
<string>keyword.control.end.ruby</string>
991+
</dict>
926992
<dict>
927-
<key>comment</key>
928-
<string>everything being a reserved word, not a value and needing a 'end' is a..</string>
929993
<key>match</key>
930-
<string>(?&lt;!\.)\b(BEGIN|END|end)\b(?![?!])</string>
994+
<string>(?&lt;!\.)\b(BEGIN|END)\b(?![?!])</string>
931995
<key>name</key>
932-
<string>keyword.control.ruby</string>
996+
<string>keyword.control.$1.ruby</string>
933997
</dict>
934998
<dict>
935999
<key>comment</key>
@@ -1164,10 +1228,15 @@
11641228
<key>comment</key>
11651229
<string>the method pattern comes from the symbol pattern, see there for a explaination</string>
11661230
<key>end</key>
1167-
<string>(?&lt;!\.|::)\bend\b(?![?!])</string>
1231+
<string>(?&lt;!\.|::)\b((end))\b(?![?!])</string>
11681232
<key>endCaptures</key>
11691233
<dict>
1170-
<key>0</key>
1234+
<key>1</key>
1235+
<dict>
1236+
<key>name</key>
1237+
<string>keyword.control.end.ruby</string>
1238+
</dict>
1239+
<key>2</key>
11711240
<dict>
11721241
<key>name</key>
11731242
<string>keyword.control.def.end.ruby</string>
@@ -1289,10 +1358,15 @@
12891358
<key>comment</key>
12901359
<string>same as the previous rule, but without parentheses around the arguments</string>
12911360
<key>end</key>
1292-
<string>(?&lt;!\.|::)\bend\b(?![?!])</string>
1361+
<string>(?&lt;!\.|::)\b((end))\b(?![?!])</string>
12931362
<key>endCaptures</key>
12941363
<dict>
1295-
<key>0</key>
1364+
<key>1</key>
1365+
<dict>
1366+
<key>name</key>
1367+
<string>keyword.control.end.ruby</string>
1368+
</dict>
1369+
<key>2</key>
12961370
<dict>
12971371
<key>name</key>
12981372
<string>keyword.control.def.end.ruby</string>
@@ -1372,10 +1446,15 @@
13721446
<key>comment</key>
13731447
<string> the optional name is just to catch the def also without a method-name</string>
13741448
<key>end</key>
1375-
<string>(?&lt;!\.|::)\bend\b(?![?!])</string>
1449+
<string>(?&lt;!\.|::)\b((end))\b(?![?!])</string>
13761450
<key>endCaptures</key>
13771451
<dict>
1378-
<key>0</key>
1452+
<key>1</key>
1453+
<dict>
1454+
<key>name</key>
1455+
<string>keyword.control.end.ruby</string>
1456+
</dict>
1457+
<key>2</key>
13791458
<dict>
13801459
<key>name</key>
13811460
<string>keyword.control.def.end.ruby</string>

0 commit comments

Comments
 (0)