Skip to content

Commit f4ee0ce

Browse files
committed
Added syntax highlight for nimble and nim.cfg files
1 parent e4906cc commit f4ee0ce

5 files changed

+316
-3
lines changed

nimble.configuration.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"wordPattern": "/(-?\\d*\\.\\d\\w*)|([^\\`\\~\\!\\@\\#\\%\\^\\&\\*\\(\\)\\-\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\'\\\"\\,\\.\\<\\>\\/\\?\\s]+)/g",
3+
"comments": {
4+
"lineComment": "#"
5+
},
6+
"brackets": [
7+
["[", "]"]
8+
]
9+
}

nimcfg.configuration.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"wordPattern": "/(-?\\d*\\.\\d\\w*)|([^\\`\\~\\!\\@\\#\\%\\^\\&\\*\\(\\)\\-\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\'\\\"\\,\\.\\<\\>\\/\\?\\s]+)/g",
3+
"comments": {
4+
"lineComment": "#"
5+
},
6+
"brackets": []
7+
}

package.json

+27-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "nim",
33
"displayName": "nim-vscode",
44
"description": "Nim language support for Visual Studio Code",
5-
"version": "0.4.1",
5+
"version": "0.4.2",
66
"publisher": "kosz78",
77
"author": {
88
"name": "Xored Software Inc."
@@ -40,6 +40,8 @@
4040
},
4141
"activationEvents": [
4242
"onLanguage:nim",
43+
"onLanguage:nimcfg",
44+
"onLanguage:nimble",
4345
"onCommand:nim.build",
4446
"onCommand:nim.run",
4547
"onCommand:nim.runTest"
@@ -50,16 +52,38 @@
5052
{
5153
"id": "nim",
5254
"aliases": ["Nim", "nim"],
53-
"extensions": [".nim"],
55+
"extensions": [".nim", ".nims"],
5456
"configuration": "./nim.configuration.json"
57+
},
58+
{
59+
"id": "nimcfg",
60+
"aliases": ["Nim Config", "nimcfg"],
61+
"extensions": [".cfg"],
62+
"configuration": "./nimcfg.configuration.json"
63+
},
64+
{
65+
"id": "nimble",
66+
"aliases": ["Nimble", "nimble"],
67+
"extensions": [".nimble"],
68+
"configuration": "./nimble.configuration.json"
5569
}
5670
],
5771
"grammars": [
5872
{
5973
"language": "nim",
6074
"scopeName": "source.nim",
6175
"path": "./syntaxes/Nim.tmLanguage"
62-
}
76+
},
77+
{
78+
"language": "nimcfg",
79+
"scopeName": "source.nimcfg",
80+
"path": "./syntaxes/Nim_Cfg.tmLanguage"
81+
},
82+
{
83+
"language": "nimble",
84+
"scopeName": "source.nimble",
85+
"path": "./syntaxes/nimble.json"
86+
}
6387
],
6488
"commands": [
6589
{

syntaxes/Nim_Cfg.tmLanguage

+184
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>fileTypes</key>
6+
<array>
7+
<string>cfg</string>
8+
</array>
9+
<key>name</key>
10+
<string>Nim Config</string>
11+
<key>patterns</key>
12+
<array>
13+
<dict>
14+
<key>captures</key>
15+
<dict>
16+
<key>1</key>
17+
<dict>
18+
<key>name</key>
19+
<string>punctuation.definition.comment.nimcfg</string>
20+
</dict>
21+
<key>2</key>
22+
<dict>
23+
<key>name</key>
24+
<string>invalid.illegal.TODO.nimcfg</string>
25+
</dict>
26+
</dict>
27+
<key>match</key>
28+
<string>(#\s*(TODO|todo)?).*$\n?</string>
29+
<key>name</key>
30+
<string>comment.line.number-sign.nimcfg</string>
31+
</dict>
32+
<dict>
33+
<key>comment</key>
34+
<string>Section declarations</string>
35+
<key>match</key>
36+
<string>\[.+\]</string>
37+
<key>name</key>
38+
<string>support.type.nimcfg</string>
39+
</dict>
40+
<dict>
41+
<key>begin</key>
42+
<string>\@\b(if|elif|else)\b</string>
43+
<key>captures</key>
44+
<dict>
45+
<key>0</key>
46+
<dict>
47+
<key>name</key>
48+
<string>keyword.control.nimcfg</string>
49+
</dict>
50+
</dict>
51+
<key>comment</key>
52+
<string>Keywords that affect program control flow or scope.</string>
53+
<key>end</key>
54+
<string>\@\b(end)</string>
55+
<key>patterns</key>
56+
<array>
57+
<dict>
58+
<key>include</key>
59+
<string>source.nimcfg</string>
60+
</dict>
61+
</array>
62+
</dict>
63+
<dict>
64+
<key>begin</key>
65+
<string>([a-zA-Z0-9_\.]+)\s*(\=)</string>
66+
<key>comment</key>
67+
<string>Key declarations</string>
68+
<key>end</key>
69+
<string>\n</string>
70+
<key>patterns</key>
71+
<array>
72+
<dict>
73+
<key>match</key>
74+
<string>\b((\d[_\d]*\.[_\d]+([eE][\+\-]?\d[_\d]*)?)|([eE][\+\-]?\d[_\d]*))('[fF](32|64))?</string>
75+
<key>name</key>
76+
<string>constant.numeric.float.decimal.nimcfg</string>
77+
</dict>
78+
<dict>
79+
<key>match</key>
80+
<string>\b(0[xX]\h[_\h]*)('[iIuU](8|16|32|64))?</string>
81+
<key>name</key>
82+
<string>constant.numeric.integer.hexadecimal.nimcfg</string>
83+
</dict>
84+
<dict>
85+
<key>comment</key>
86+
<string>For simplicity's sake, we don't enforce floats only having 32 and 64 prefix types.</string>
87+
<key>match</key>
88+
<string>\b(0o[0-7][_0-7]*)</string>
89+
<key>name</key>
90+
<string>constant.numeric.integer.octal.nimcfg</string>
91+
</dict>
92+
<dict>
93+
<key>match</key>
94+
<string>\b(0(b|B)[01][_01]*)</string>
95+
<key>name</key>
96+
<string>constant.numeric.integer.binary.nimcfg</string>
97+
</dict>
98+
<dict>
99+
<key>match</key>
100+
<string>\b(\d[_\d]*)</string>
101+
<key>name</key>
102+
<string>constant.numeric.integer.decimal.nimcfg</string>
103+
</dict>
104+
<dict>
105+
<key>comment</key>
106+
<string>Language Constants.</string>
107+
<key>match</key>
108+
<string>\b(true|false)\b</string>
109+
<key>name</key>
110+
<string>constant.language.nimcfg</string>
111+
</dict>
112+
<dict>
113+
<key>begin</key>
114+
<string>r\"</string>
115+
<key>comment</key>
116+
<string>Raw Double Quoted String</string>
117+
<key>end</key>
118+
<string>\"</string>
119+
<key>name</key>
120+
<string>string.quoted.double.raw.nimcfg</string>
121+
<key>patterns</key>
122+
<array>
123+
<dict>
124+
<key>match</key>
125+
<string>\"\"</string>
126+
</dict>
127+
</array>
128+
</dict>
129+
<dict>
130+
<key>begin</key>
131+
<string>\"</string>
132+
<key>captures</key>
133+
<dict>
134+
<key>1</key>
135+
<dict>
136+
<key>name</key>
137+
<string>storage.type.function.nimcfg</string>
138+
</dict>
139+
</dict>
140+
<key>comment</key>
141+
<string>Double Quoted String</string>
142+
<key>end</key>
143+
<string>\"</string>
144+
<key>name</key>
145+
<string>string.quoted.double.nimcfg</string>
146+
<key>patterns</key>
147+
<array>
148+
<dict>
149+
<key>match</key>
150+
<string>(\\([abenrclftv\\]|["']|[0-9])|x\h\h)</string>
151+
</dict>
152+
</array>
153+
</dict>
154+
<dict>
155+
<key>comment</key>
156+
<string>Single quoted character literal</string>
157+
<key>match</key>
158+
<string>\'(\\\d{1,3}|\\?[^\n]?)\'</string>
159+
<key>name</key>
160+
<string>string.quoted.single.nimcfg</string>
161+
</dict>
162+
<dict>
163+
<key>captures</key>
164+
<dict>
165+
<key>1</key>
166+
<dict>
167+
<key>name</key>
168+
<string>string.raw.nimcfg</string>
169+
</dict>
170+
</dict>
171+
<key>comment</key>
172+
<string>Value declarations</string>
173+
<key>match</key>
174+
<string>\b(.+)\b</string>
175+
</dict>
176+
</array>
177+
</dict>
178+
</array>
179+
<key>scopeName</key>
180+
<string>source.nimcfg</string>
181+
<key>uuid</key>
182+
<string>8fb54f5c-6f67-4d13-9dcc-52650ea4cb3e</string>
183+
</dict>
184+
</plist>

syntaxes/nimble.json

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
{
2+
"name": "nimble",
3+
"scopeName": "source.nimble",
4+
"fileTypes": [ "nimble" ],
5+
"foldingStartMarker": "",
6+
"foldingStopMarker": "",
7+
"patterns": [
8+
{ "include": "#comments" },
9+
{ "include": "#strings" },
10+
{ "include": "#category" },
11+
{ "include": "#keywords" },
12+
{ "include": "#text" }
13+
],
14+
"repository": {
15+
"category": {
16+
"patterns": [
17+
{
18+
"name": "keyword.control.nimble",
19+
"match": "^\\[\\w+\\]$"
20+
}
21+
]
22+
},
23+
"comments": {
24+
"patterns": [
25+
{
26+
"name": "comment.line.nimble",
27+
"match": "#.*$"
28+
}
29+
]
30+
},
31+
"keywords": {
32+
"patterns": [
33+
{
34+
"name": "entity.name.section.nimble",
35+
"match": "author|name|version|description|license"
36+
},
37+
{
38+
"name": "variable.nimble",
39+
"match": "SkipDirs|SkipFiles|SkipExt|InstallDirs|InstallFiles|InstallExt|srcDir|binDir|bin|backend|requires"
40+
},
41+
{
42+
"name": "meta.selector.nimble",
43+
"match": "\\:"
44+
}
45+
]
46+
},
47+
"strings": {
48+
"patterns": [
49+
{
50+
"name": "string.quoted.double.nimble",
51+
"begin": "(?=[^\\\\])(\")",
52+
"end": "(\")",
53+
"beginCaptures": {
54+
"1": {
55+
"name": "punctuation.definition.string.begin.nimble"
56+
}
57+
},
58+
"endCaptures": {
59+
"1": {
60+
"name": "punctuation.definition.string.end.nimble"
61+
}
62+
},
63+
"patterns": [
64+
{
65+
"name": "punctuation.separator.string.ignore-eol.nimble",
66+
"match": "\\\\$[ \\t]*"
67+
},
68+
{
69+
"name": "constant.character.string.escape.nimble",
70+
"match": "\\\\([\\\\''ntbr]|u[a-fA-F0-9]{4}|u[a-fA-F0-9]{8})"
71+
},
72+
{
73+
"name": "invalid.illeagal.character.string.nimble",
74+
"match": "\\\\(?![\\\\''ntbr]|u[a-fA-F0-9]{4}|u[a-fA-F0-9]{8})."
75+
}
76+
]
77+
}
78+
]
79+
},
80+
"text": {
81+
"patterns": [
82+
{
83+
"name": "text.nimble",
84+
"match": "\\\\"
85+
}
86+
]
87+
}
88+
}
89+
}

0 commit comments

Comments
 (0)