Skip to content

Commit 31f919f

Browse files
authored
Add syntax highlighting (#42)
Add syntax highlighting. Now it's no longer necessary to use a separate extension. Fixes #41.
1 parent 7ec9a23 commit 31f919f

File tree

5 files changed

+202
-5
lines changed

5 files changed

+202
-5
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# v0.7.0
2+
3+
## New Features
4+
5+
* Add syntax highlighting. Now it's no longer necessary to use a separate extension.
6+
17
# v0.6.1
28

39
## Bug Fixes

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ See errors on the fly as you write the code, before running FASTBuild.
4242

4343
## Limitations
4444

45-
* The extension does not yet provide syntax highlighting. For that in the meantime, I recommend the FASTBuild (`roscop.fastbuild`) extension ([extension website](https://marketplace.visualstudio.com/items?itemName=RoscoP.fastbuild)).
4645
* Only evaluates code if it is called at least once. This means, for example, that you cannot jump to the definition of a variable defined inside a user function if that user function is never called.
4746

4847
## Compatibility

fastbuild.tmLanguage.json

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
3+
"name": "FASTBuild",
4+
"scopeName": "source.fastbuild",
5+
"patterns": [
6+
{
7+
"include": "#comment"
8+
},
9+
{
10+
"include": "#operator"
11+
},
12+
{
13+
"include": "#string_single_quote"
14+
},
15+
{
16+
"include": "#string_double_quote"
17+
},
18+
{
19+
"include": "#builtin_define"
20+
},
21+
{
22+
"include": "#builtin_variable"
23+
},
24+
{
25+
"include": "#directive"
26+
},
27+
{
28+
"include": "#directive_function"
29+
},
30+
{
31+
"include": "#define_symbol"
32+
},
33+
{
34+
"include": "#constant"
35+
},
36+
{
37+
"include": "#variable"
38+
},
39+
{
40+
"include": "#function"
41+
}
42+
],
43+
"repository": {
44+
"comment": {
45+
"patterns": [
46+
{
47+
"name": "comment.line.double-slash.fastbuild",
48+
"match": "(?://|;).*"
49+
}
50+
]
51+
},
52+
"operator": {
53+
"patterns": [
54+
{
55+
"name": "keyword.operator.comparison.fastbuild",
56+
"match": "(?:<=|>=|==|<|>)"
57+
},
58+
{
59+
"name": "keyword.operator.assignment.fastbuild",
60+
"match": "(?:\\+|-|=)"
61+
},
62+
{
63+
"name": "keyword.operator.logical.fastbuild",
64+
"match": "!"
65+
},
66+
{
67+
"name": "keyword.operator.expression.fastbuild",
68+
"match": "\\bin\\b"
69+
}
70+
]
71+
},
72+
"string_embed": {
73+
"patterns": [
74+
{
75+
"name": "constant.character.escape.fastbuild",
76+
"match": "\\^.|\\$[\\w]+\\$|%\\d+"
77+
}
78+
]
79+
},
80+
"string_single_quote": {
81+
"name": "string.quoted.single.fastbuild",
82+
"begin": "'",
83+
"end": "'",
84+
"patterns": [
85+
{
86+
"include": "#string_embed"
87+
}
88+
]
89+
},
90+
"string_double_quote": {
91+
"name": "string.quoted.double.fastbuild",
92+
"begin": "\"",
93+
"end": "\"",
94+
"patterns": [
95+
{
96+
"include": "#string_embed"
97+
}
98+
]
99+
},
100+
"builtin_define": {
101+
"patterns": [
102+
{
103+
"name": "variable.language.fastbuild",
104+
"match": "__WINDOWS__|__OSX__|__LINUX__"
105+
}
106+
]
107+
},
108+
"builtin_variable": {
109+
"patterns": [
110+
{
111+
"match": "[\\.^](_CURRENT_BFF_DIR_|_FASTBUILD_VERSION_STRING_|_FASTBUILD_VERSION_|_FASTBUILD_EXE_PATH_|_WORKING_DIR_)",
112+
"captures": {
113+
"1": {
114+
"name": "variable.language.fastbuild"
115+
}
116+
}
117+
}
118+
]
119+
},
120+
"directive": {
121+
"patterns": [
122+
{
123+
"name": "keyword.other.fastbuild",
124+
"match": "#(?:if|else|endif|include|once)"
125+
}
126+
]
127+
},
128+
"directive_function": {
129+
"patterns": [
130+
{
131+
"name": "keyword.function.fastbuild",
132+
"match": "\\b(?:exists|file_exists)\\b"
133+
}
134+
]
135+
},
136+
"define_symbol": {
137+
"patterns": [
138+
{
139+
"name": "keyword.other.fastbuild",
140+
"match": "#(?:define|undef|import)\\s+([\\w]+)",
141+
"captures": {
142+
"1": {
143+
"name": "variable.parameter.fastbuild"
144+
}
145+
}
146+
}
147+
]
148+
},
149+
"constant": {
150+
"patterns": [
151+
{
152+
"name": "constant.language.fastbuild",
153+
"match": "\\b(?:true|false)\\b"
154+
}
155+
]
156+
},
157+
"variable": {
158+
"patterns": [
159+
{
160+
"match": "[\\.^]([\\w\\$]+)",
161+
"captures": {
162+
"1": {
163+
"name": "variable.other.fastbuild"
164+
}
165+
}
166+
},
167+
{
168+
"match": "[\\.^](['\"])([\\w\\$]+)\\1",
169+
"captures": {
170+
"2": {
171+
"name": "variable.other.fastbuild"
172+
}
173+
}
174+
}
175+
]
176+
},
177+
"function": {
178+
"patterns": [
179+
{
180+
"name": "support.function.fastbuild",
181+
"match": "\\b(?:Alias|Compiler|Copy|CopyDir|CSAssembly|DLL|Error|Exec|Executable|ForEach|If|Library|ListDependencies|ObjectList|Print|RemoveDir|Settings|Test|TextFile|Unity|Using|VCXProject|VSProjectExternal|VSSolution|XCodeProject)\\b"
182+
}
183+
]
184+
}
185+
}
186+
}

language-configuration.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"comments": {
3-
"lineComment": "//",
4-
"blockComment": [ "/*", "*/" ]
3+
"lineComment": "//"
54
},
65
"brackets": [
76
[ "{", "}" ],

package.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "fastbuild-support",
33
"displayName": "FASTBuild Support",
44
"description": "FASTBuild language support. Includes go-to definition, find references, variable evaluation, syntax errors, etc.",
5-
"version": "0.6.1",
5+
"version": "0.7.0",
66
"preview": true,
77
"publisher": "HarrisonT",
88
"author": {
@@ -38,7 +38,14 @@
3838
"id": "fastbuild",
3939
"aliases": ["FASTBuild", "fastbuild"],
4040
"extensions": [".bff"],
41-
"configuration": "language-configuration.json"
41+
"configuration": "./language-configuration.json"
42+
}
43+
],
44+
"grammars": [
45+
{
46+
"language": "fastbuild",
47+
"scopeName": "source.fastbuild",
48+
"path": "./fastbuild.tmLanguage.json"
4249
}
4350
],
4451
"configuration": {

0 commit comments

Comments
 (0)