Skip to content

Commit ff494fb

Browse files
committed
syntax: highlight custom types after As
fix #26
1 parent 0e37cb3 commit ff494fb

File tree

2 files changed

+30
-17
lines changed

2 files changed

+30
-17
lines changed

syntaxes/tests/types.bas

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,38 @@
11
' SYNTAX TEST "source.vba" "types"
22

33
Dim bool As Boolean
4-
' ^^^^^^^ support.type
4+
' ^^^^^^^ support.type.builtin
55
Dim b As Byte
6-
' ^^^^ support.type
6+
' ^^^^ support.type.builtin
77
Dim cur As Currency
8-
' ^^^^^^^^ support.type
8+
' ^^^^^^^^ support.type.builtin
99
Dim col As Collection
10-
' ^^^^^^^^^^ support.type
10+
' ^^^^^^^^^^ support.type.builtin
1111
Dim dt As Date
12-
' ^^^^ support.type
12+
' ^^^^ support.type.builtin
1313
Dim db As Double
14-
' ^^^^^^ support.type
14+
' ^^^^^^ support.type.builtin
1515
Dim i As Integer
16-
' ^^^^^^^ support.type
16+
' ^^^^^^^ support.type.builtin
1717
Dim l As Long
18-
' ^^^^ support.type
18+
' ^^^^ support.type.builtin
1919
Dim ll As LongLong
20-
' ^^^^^^^^ support.type
20+
' ^^^^^^^^ support.type.builtin
2121
Dim lptr As LongPtr
22-
' ^^^^^^^ support.type
22+
' ^^^^^^^ support.type.builtin
2323
Dim obj As Object
24-
' ^^^^^^ support.type
24+
' ^^^^^^ support.type.builtin
2525
Dim sing As Single
26-
' ^^^^^^ support.type
26+
' ^^^^^^ support.type.builtin
2727
Dim s As String
28-
' ^^^^^^ support.type
28+
' ^^^^^^ support.type.builtin
2929
Dim v as Variant
30-
' ^^^^^^^ support.type
30+
' ^^^^^^^ support.type.builtin
31+
32+
Dim spam as MyVarType
33+
' ^^^^^^^^^ support.type
34+
35+
Sub eggs(p As ParamType) as RetType
36+
' ^^^^^^^^^ support.type
37+
' ^^^^^^^^ support.type
38+
End Sub

syntaxes/vba.tmGrammar.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,18 @@ repository:
5656
storage:
5757
patterns:
5858
- name: storage.modifier.vba
59-
match: (?i:\b(Class|Const|Dim|(G|L|S)et|ReDim( Preserve)?)\b)
59+
match: (?i)\b(Class|Const|Dim|(G|L|S)et|ReDim( Preserve)?)\b
6060

6161
strings:
6262
name: string.quoted.double
6363
begin: '"'
6464
end: '"'
6565

6666
types:
67-
name: support.type
68-
match: (?i)\b(Byte|Boolean|Currency|Collection|Date|Double|Integer|Long(Long|Ptr)?|Object|Single|String)|Variant\b
67+
patterns:
68+
- name: support.type.builtin
69+
match: (?i)\b(Byte|Boolean|Currency|Collection|Date|Double|Integer|Long(Long|Ptr)?|Object|Single|String)|Variant\b
70+
- match: (?i)(?<=As\s+)([a-zA-Z]+)
71+
captures:
72+
1:
73+
name: support.type

0 commit comments

Comments
 (0)