Skip to content

Commit a8328ab

Browse files
committed
Grammar: Mark types in var x Type & x := Type{
1 parent 4fd348f commit a8328ab

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

Syntaxes/Go.tmLanguage

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,11 +445,27 @@
445445
</dict>
446446
</array>
447447
</dict>
448+
<key>3</key>
449+
<dict>
450+
<key>patterns</key>
451+
<array>
452+
<dict>
453+
<key>include</key>
454+
<string>#keywords</string>
455+
</dict>
456+
<dict>
457+
<key>match</key>
458+
<string>[[:alpha:]_]\w*\b(?!\.)</string>
459+
<key>name</key>
460+
<string>support.type.go</string>
461+
</dict>
462+
</array>
463+
</dict>
448464
</dict>
449465
<key>comment</key>
450466
<string>This matches the 'var x' style of variable declaration.</string>
451467
<key>match</key>
452-
<string>^\s*(var)\s+((?:[[:alpha:]_]\w*)(?:,\s+[[:alpha:]_]\w*)*)</string>
468+
<string>^\s*(var)\s+((?:[[:alpha:]_]\w*)(?:,\s+[[:alpha:]_]\w*)*)\s*(.*)\s*(?:=|$)</string>
453469
<key>name</key>
454470
<string>meta.initialization.explicit.go</string>
455471
</dict>
@@ -473,11 +489,27 @@
473489
<key>name</key>
474490
<string>keyword.operator.go</string>
475491
</dict>
492+
<key>3</key>
493+
<dict>
494+
<key>patterns</key>
495+
<array>
496+
<dict>
497+
<key>include</key>
498+
<string>#keywords</string>
499+
</dict>
500+
<dict>
501+
<key>match</key>
502+
<string>[[:alpha:]_]\w*\b(?!\.)</string>
503+
<key>name</key>
504+
<string>support.type.go</string>
505+
</dict>
506+
</array>
507+
</dict>
476508
</dict>
477509
<key>comment</key>
478510
<string>This matches the 'x :=' style of variable declaration.</string>
479511
<key>match</key>
480-
<string>((?:[[:alpha:]_]\w*)(?:\s*,\s+[[:alpha:]_]\w*)*)\s*(:=)</string>
512+
<string>((?:[[:alpha:]_]\w*)(?:\s*,\s+[[:alpha:]_]\w*)*)\s*(:=)(?:\s*([[:alpha:]_]\w*)\s*\{)?</string>
481513
<key>name</key>
482514
<string>meta.initialization.short.go</string>
483515
</dict>

0 commit comments

Comments
 (0)