Skip to content

Commit 60597b8

Browse files
committed
Fix several bugs in fgd syntax highlighting
1 parent 90e73a5 commit 60597b8

2 files changed

Lines changed: 58 additions & 15 deletions

File tree

samples/fgd/test.fgd

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,23 @@
22
= test : "This is a test entity definition for syntax highlighting"
33
[
44

5+
KeyvalueExample1[engine](string) : "Keyvalue Display Name" : "Default" : "Description"
6+
KeyvalueExample2[!engine](string) : "Keyvalue Display Name" : 1 : "Description"
7+
KeyvalueExample3[P2, CSGO](string) : "Keyvalue Display Name" : "Default" : "Description"
8+
59
spawnflags(flags) =
610
[
711
1 : "Flag" : 0
12+
2 : "Flag 2" : 0 [TF2]
13+
]
14+
15+
choicestest(choices) : "Test test" : 0 : "Hello" =
16+
[
17+
0 : "Choice 1"
18+
1 : "Choice 2" [TF2]
819
]
920

10-
KeyvalueExample(string) : "Keyvalue Display Name" : "Default" : "Description"
21+
KeyvalueExample4(string) : "Keyvalue Display Name" : "Default" : "Description"
1122

1223
input InputExample(void) : "Description"
1324

syntaxes/fgd.tmLanguage.json

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
},
7878
"head": {
7979
"name": "meta.head.fgd",
80-
"match": "([\\w]+:)",
80+
"match": "([\\w]+ *:)",
8181
"captures": {
8282
"1": {
8383
"name": "entity.name.class.fgd"
@@ -90,7 +90,8 @@
9090
"end": "\\]",
9191
"patterns": [
9292
{
93-
"include": "#keyvalueName"
93+
"match": "(input|output)",
94+
"name": "storage.modifier"
9495
},
9596
{
9697
"include": "#array"
@@ -105,27 +106,31 @@
105106
"include": "source.kv#stringQuoted"
106107
},
107108
{
108-
"include": "#description"
109+
"include": "#keyvalueName"
109110
},
110111
{
111-
"match": "(input|output)",
112-
"name": "storage.modifier"
112+
"include": "#description"
113113
}
114114
]
115115
},
116116
"keyvalueName": {
117-
"match": "(\\w+)(\\[\\w+\\])?\\((axis|angle|angle_negative_pitch|color255|color1|filterclass|instance_file|instance_parm|instance_variable|material|node_dest|node_id|npcclass|origin|particlesystem|pointentityclass|scene|script|scriptlist|sidelist|sound|sprite|decal|studio|target_destination|target_name_or_class|target_source|vecline|vector|string|integer|float|boolean|choices|flags|void)\\)",
118-
"captures": {
119-
"1": {
117+
"begin": "\\w+",
118+
"beginCaptures": {
119+
"0": {
120120
"name": "entity.name.function.fgd"
121-
},
122-
"2": {
123-
"name": "meta.preprocessor.fgd"
124-
},
125-
"3": {
121+
}
122+
},
123+
"end": "\\((axis|angle|angle_negative_pitch|color255|color1|filterclass|instance_file|instance_parm|instance_variable|material|node_dest|node_id|npcclass|origin|particlesystem|pointentityclass|scene|script|scriptlist|sidelist|sound|sprite|decal|studio|target_destination|target_name_or_class|target_source|vecline|vector|string|integer|float|boolean|choices|flags|void)\\)",
124+
"endCaptures": {
125+
"1": {
126126
"name": "variable.parameter.fgd"
127127
}
128-
}
128+
},
129+
"patterns": [
130+
{
131+
"include": "#preprocessorTag"
132+
}
133+
]
129134
},
130135
"array": {
131136
"begin": "\\[",
@@ -136,6 +141,9 @@
136141
},
137142
{
138143
"include": "source.kv#stringQuoted"
144+
},
145+
{
146+
"include": "#preprocessorTag"
139147
}
140148
]
141149
},
@@ -154,6 +162,30 @@
154162
"name": "constant.character.escape.fgd"
155163
}
156164
]
165+
},
166+
"preprocessorTag": {
167+
"begin": "\\[",
168+
"end": "\\]",
169+
"beginCaptures": {
170+
"0": {
171+
"name": "keyword.operator.fgd"
172+
}
173+
},
174+
"endCaptures": {
175+
"0": {
176+
"name": "keyword.operator.fgd"
177+
}
178+
},
179+
"patterns": [
180+
{
181+
"match": "(\\w+)",
182+
"name": "entity.name.tag.fgd"
183+
},
184+
{
185+
"match": "!",
186+
"name": "keyword.control.fgd"
187+
}
188+
]
157189
}
158190
}
159191
}

0 commit comments

Comments
 (0)