Skip to content

Commit 6c28272

Browse files
committed
Merge branch 'master' of github.com:spamwax/sublime-rust into spamwax-master
Conflicts: test.sublime-snippet
2 parents 1e1d3bd + 4c9cc1f commit 6c28272

16 files changed

+147
-58
lines changed

Ok.sublime-snippet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<snippet>
2-
<content><![CDATA[Ok(${1})]]></content>
2+
<content><![CDATA[Ok(${1:result})]]></content>
33
<tabTrigger>Ok</tabTrigger>
44
<scope>source.rust</scope>
55
<description>Ok(…)</description>

Rust.JSON-tmLanguage

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"foldingStopMarker": "^\\s*\\}",
66
"patterns": [
77
{"name": "variable.other.source.rust",
8-
"match": "'[a-zA-Z_][a-zA-Z0-9_]*(?=[^\'])"
8+
"match": "'[a-zA-Z_][a-zA-Z0-9_]*(?=[^\\'])"
99
},
1010
{"name": "string.quoted.single.source.rust",
1111
"begin": "'",
@@ -22,11 +22,29 @@
2222
]
2323
},
2424
{"name": "meta.function.source.rust",
25-
"match": "\\b(fn)\\s+([a-zA-Z_][a-zA-Z0-9_]?[\\w\\:,+ \\'<>]*)\\s*(\\()",
25+
"match": "\\b(fn)\\s+([a-zA-Z_][a-zA-Z0-9_]?[\\w\\:,+ \\'<>]*)\\s*(?:\\()",
2626
"captures": {
2727
"1": {"name": "keyword.source.rust"},
28-
"2": {"name": "entity.name.function.source.rust"},
29-
"3": {"name": "keyword.operator.rust"}
28+
"2": {"name": "entity.name.function.source.rust"}
29+
}
30+
},
31+
{
32+
"name": "meta.initialization.rust",
33+
"match": "(let)\\s+([[:alpha:]_][[:alnum:]_]*)\\s*(:(.+))?\\s*(=)",
34+
"captures": {
35+
"1": {"name": "keyword.source.rust"},
36+
"2": {"name": "variable.other.rust"},
37+
"4": {"name": "storage.type.source.rust"},
38+
"5": {"name": "keyword.operator.rust"}
39+
},
40+
"comment": "This matches the 'let x = val' style of variable intitialization."
41+
},
42+
{
43+
"name": "meta.import.rust",
44+
"match": "(extern\\s+crate)\\s+(\\w+)",
45+
"captures": {
46+
"1": {"name": "keyword.source.rust"},
47+
"2": {"name": "support"}
3048
}
3149
},
3250
{"name": "keyword.source.rust",
@@ -44,17 +62,14 @@
4462
{"name": "support.constant.source.rust",
4563
"match": "\\b(EXIT_FAILURE|EXIT_SUCCESS|RAND_MAX|EOF|SEEK_SET|SEEK_CUR|SEEK_END|_IOFBF|_IONBF|_IOLBF|BUFSIZ|FOPEN_MAX|FILENAME_MAX|L_tmpnam|TMP_MAX|O_RDONLY|O_WRONLY|O_RDWR|O_APPEND|O_CREAT|O_EXCL|O_TRUNC|S_IFIFO|S_IFCHR|S_IFBLK|S_IFDIR|S_IFREG|S_IFMT|S_IEXEC|S_IWRITE|S_IREAD|S_IRWXU|S_IXUSR|S_IWUSR|S_IRUSR|F_OK|R_OK|W_OK|X_OK|STDIN_FILENO|STDOUT_FILENO|STDERR_FILENO)\\b"
4664
},
47-
{"name": "comment.block.preprocessor.rust",
48-
"match": "^(\\w\\(\\w\\)*!)|(#\\[[\\w=\\(\\)_]+\\])$"
49-
},
50-
{"name": "keyword.operator.rust",
51-
"match": "\\{|\\}"
52-
},
53-
{"name": "keyword.operator.rust",
54-
"match": "\\[|\\]"
55-
},
56-
{"name": "keyword.operator.rust",
57-
"match": "\\(|\\)"
65+
{"name": "comment.block.attribute.rust",
66+
"begin": "#\\[",
67+
"end": "\\]",
68+
"patterns": [
69+
{ "name": "string.quoted.double",
70+
"match": "\".+?\""
71+
}
72+
]
5873
},
5974
{"name": "constant.numeric.integer.source.rust",
6075
"match": "\\b(([0-9][0-9_]*)|([0-9][0-9_]*(u|u8|u16|u32|u64))|([0-9][0-9_]*(i|i8|i16|i32|i64)))\\b"
@@ -81,10 +96,22 @@
8196
"end": "\\*/"
8297
},
8398
{"name": "keyword.operator.rust",
84-
"match": "(=>)|(->)|[-:=*,!.+|%/&amp;~@<>;]"
99+
"match": "(=>)|(->)|[-:=*,!.+|%/&~@<>;]"
85100
},
86101
{"name": "support.function.rust",
87102
"match": "_"
103+
},
104+
{"name": "support.function.rust",
105+
"match": "\\b(\\w+)\\b(?=\\()"
106+
},
107+
{"name": "meta.namespace-block.rust",
108+
"match": "\\b(\\w+)::"
109+
},
110+
{"name": "meta.preprocessor.rust",
111+
"match": "\\b(\\w+)!"
112+
},
113+
{"match": "(\\[|\\]|{|}|\\(|\\))",
114+
"name": "punctuation.definition.bracket.rust"
88115
}
89116
],
90117
"repository": {

Rust.tmLanguage

Lines changed: 86 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,61 @@
6464
<key>name</key>
6565
<string>entity.name.function.source.rust</string>
6666
</dict>
67-
<key>3</key>
67+
</dict>
68+
<key>match</key>
69+
<string>\b(fn)\s+([a-zA-Z_][a-zA-Z0-9_]?[\w\:,+ \'&lt;&gt;]*)\s*(?:\()</string>
70+
<key>name</key>
71+
<string>meta.function.source.rust</string>
72+
</dict>
73+
<dict>
74+
<key>captures</key>
75+
<dict>
76+
<key>1</key>
77+
<dict>
78+
<key>name</key>
79+
<string>keyword.source.rust</string>
80+
</dict>
81+
<key>2</key>
82+
<dict>
83+
<key>name</key>
84+
<string>variable.other.rust</string>
85+
</dict>
86+
<key>4</key>
87+
<dict>
88+
<key>name</key>
89+
<string>storage.type.source.rust</string>
90+
</dict>
91+
<key>5</key>
6892
<dict>
6993
<key>name</key>
7094
<string>keyword.operator.rust</string>
7195
</dict>
7296
</dict>
97+
<key>comment</key>
98+
<string>This matches the 'let x = val' style of variable intitialization.</string>
7399
<key>match</key>
74-
<string>\b(fn)\s+([a-zA-Z_][a-zA-Z0-9_]?[\w\:,+ \'&lt;&gt;]*)\s*(\()</string>
100+
<string>(let)\s+([[:alpha:]_][[:alnum:]_]*)\s*(:(.+))?\s*(=)</string>
75101
<key>name</key>
76-
<string>meta.function.source.rust</string>
102+
<string>meta.initialization.rust</string>
103+
</dict>
104+
<dict>
105+
<key>captures</key>
106+
<dict>
107+
<key>1</key>
108+
<dict>
109+
<key>name</key>
110+
<string>keyword.source.rust</string>
111+
</dict>
112+
<key>2</key>
113+
<dict>
114+
<key>name</key>
115+
<string>support</string>
116+
</dict>
117+
</dict>
118+
<key>match</key>
119+
<string>(extern\s+crate)\s+(\w+)</string>
120+
<key>name</key>
121+
<string>meta.import.rust</string>
77122
</dict>
78123
<dict>
79124
<key>match</key>
@@ -106,28 +151,21 @@
106151
<string>support.constant.source.rust</string>
107152
</dict>
108153
<dict>
109-
<key>match</key>
110-
<string>^(\w\(\w\)*!)|(#\[[\w=\(,\s\)_]+\])$</string>
111-
<key>name</key>
112-
<string>comment.block.preprocessor.rust</string>
113-
</dict>
114-
<dict>
115-
<key>match</key>
116-
<string>\{|\}</string>
117-
<key>name</key>
118-
<string>keyword.operator.rust</string>
119-
</dict>
120-
<dict>
121-
<key>match</key>
122-
<string>\(|\)</string>
123-
<key>name</key>
124-
<string>keyword.operator.rust</string>
125-
</dict>
126-
<dict>
127-
<key>match</key>
128-
<string>\[|\]</string>
154+
<key>begin</key>
155+
<string>#\[</string>
156+
<key>end</key>
157+
<string>\]</string>
129158
<key>name</key>
130-
<string>keyword.operator.rust</string>
159+
<string>comment.block.attribute.rust</string>
160+
<key>patterns</key>
161+
<array>
162+
<dict>
163+
<key>match</key>
164+
<string>".+?"</string>
165+
<key>name</key>
166+
<string>string.quoted.double</string>
167+
</dict>
168+
</array>
131169
</dict>
132170
<dict>
133171
<key>match</key>
@@ -189,6 +227,30 @@
189227
<key>name</key>
190228
<string>support.function.rust</string>
191229
</dict>
230+
<dict>
231+
<key>match</key>
232+
<string>\b(\w+)\b(?=\()</string>
233+
<key>name</key>
234+
<string>support.function.rust</string>
235+
</dict>
236+
<dict>
237+
<key>match</key>
238+
<string>\b(\w+)::</string>
239+
<key>name</key>
240+
<string>meta.namespace-block.rust</string>
241+
</dict>
242+
<dict>
243+
<key>match</key>
244+
<string>\b(\w+)!</string>
245+
<key>name</key>
246+
<string>meta.preprocessor.rust</string>
247+
</dict>
248+
<dict>
249+
<key>match</key>
250+
<string>(\[|\]|{|}|\(|\))</string>
251+
<key>name</key>
252+
<string>punctuation.definition.bracket.rust</string>
253+
</dict>
192254
</array>
193255
<key>repository</key>
194256
<dict>

const.sublime-snippet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<snippet>
2-
<content><![CDATA[const ${1}: ${2} = ${4}]]></content>
2+
<content><![CDATA[const ${1:var}: ${2:typ} = ${4:val}]]></content>
33
<tabTrigger>const</tabTrigger>
44
<scope>source.rust</scope>
55
<description>const …: … = …</description>

do.sublime-snippet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<snippet>
22
<content><![CDATA[do ${1} {
3-
${2}
3+
${2:// Add code here}
44
}]]></content>
55
<tabTrigger>do</tabTrigger>
66
<scope>source.rust</scope>

enum.sublime-snippet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<snippet>
22
<content><![CDATA[enum ${1:Name} {
3-
${2}
3+
${2:variant1}
44
}]]></content>
55
<tabTrigger>enum</tabTrigger>
66
<scope>source.rust</scope>

fn.sublime-snippet

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<snippet>
2-
<content><![CDATA[fn ${1:name}(${2}) ${3}{
3-
${4}
2+
<content><![CDATA[fn ${1:name}(${2:arg}: ${3:typ}) -> ${4:ret} {
3+
${5:// add code here}
44
}]]></content>
55
<tabTrigger>fn</tabTrigger>
66
<scope>source.rust</scope>

for.sublime-snippet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<snippet>
22
<content><![CDATA[for ${1} {
3-
${2}
3+
${2:// Add code here}
44
}]]></content>
55
<tabTrigger>for</tabTrigger>
66
<scope>source.rust</scope>

loop.sublime-snippet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<snippet>
22
<content><![CDATA[loop {
3-
${1}
3+
${1:// Add code here}
44
}]]></content>
55
<tabTrigger>loop</tabTrigger>
66
<scope>source.rust</scope>

main.sublime-snippet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<snippet>
22
<content><![CDATA[fn main() {
3-
${1}
3+
${1:// Add code here}
44
}]]></content>
55
<tabTrigger>main</tabTrigger>
66
<scope>source.rust</scope>

match.sublime-snippet

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<snippet>
2-
<content><![CDATA[match ${1} {
3-
${2}
2+
<content><![CDATA[match ${1:foo} {
3+
${2:Some()} => ${3:expr},
44
}]]></content>
55
<tabTrigger>match</tabTrigger>
66
<scope>source.rust</scope>

struct.sublime-snippet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<snippet>
22
<content><![CDATA[struct ${1:Name} {
3-
${2}
3+
${2:Field}: ${3:typ}
44
}]]></content>
55
<tabTrigger>struct</tabTrigger>
66
<scope>source.rust</scope>

test.sublime-snippet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<snippet>
22
<content><![CDATA[#[test]
33
fn ${1:name}() {
4-
${2}
4+
${2: // Add code here}
55
}]]></content>
66
<tabTrigger>test</tabTrigger>
77
<scope>source.rust</scope>

trait.sublime-snippet

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<snippet>
2-
<content><![CDATA[trait ${1} {
3-
${2}
2+
<content><![CDATA[trait ${1:Name} {
3+
${2:// Add code here}
44
}
55
]]></content>
66
<tabTrigger>trait</tabTrigger>

type.sublime-snippet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<snippet>
2-
<content><![CDATA[type ${1} = ${2}]]></content>
2+
<content><![CDATA[type ${1:typ_alias} = ${2:typ}]]></content>
33
<tabTrigger>type</tabTrigger>
44
<scope>source.rust</scope>
55
<description>type … = …</description>

while.sublime-snippet

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<snippet>
2-
<content><![CDATA[while ${1} {
3-
${2}
2+
<content><![CDATA[while ${1:_condition_} {
3+
${2:// Add code here}
44
}]]></content>
55
<tabTrigger>while</tabTrigger>
66
<scope>source.rust</scope>

0 commit comments

Comments
 (0)