@@ -0,0 +1,234 @@
1+%YAML 1.2
2+---
3+# http://www.sublimetext.com/docs/3/syntax.html
4+name: "F#"
5+file_extensions:
6+ - fs
7+ - fsi
8+ - fsx
9+scope: source.fsharp
10+contexts:
11+ main:
12+ - include: comments
13+ - include: constants
14+ - include: structure
15+ - include: attributes
16+ - include: strings
17+ - include: definition
18+ - include: method_calls
19+ - include: modules
20+ - include: anonymous_functions
21+ - include: keywords
22+ anonymous_functions:
23+ - match: \b(fun)\b
24+ captures:
25+ 1: keyword.other.function-definition.fsharp
26+ push:
27+ - meta_scope: meta.function.anonymous
28+ - match: (->)
29+ captures:
30+ 1: keyword.other.fsharp
31+ pop: true
32+ - include: variables
33+ attributes:
34+ - match: '\[\<'
35+ push:
36+ - meta_scope: support.function.attribute.fsharp
37+ - match: '\>\]'
38+ pop: true
39+ - include: main
40+ characters:
41+ - match: (')
42+ captures:
43+ 1: punctuation.definition.string.begin.fsharp
44+ push:
45+ - meta_scope: string.quoted.single.fsharp
46+ - match: (')
47+ captures:
48+ 1: punctuation.definition.string.end.fsharp
49+ pop: true
50+ - match: '\\$[ \t]*'
51+ scope: punctuation.separator.string.ignore-eol.fsharp
52+ - match: '\\([\\""ntbr]|u[a-fA-F0-9]{4}|u[a-fA-F0-9]{8})'
53+ scope: constant.character.string.escape.fsharp
54+ - match: '\\(?![\\''ntbr]|u[a-fA-F0-9]{4}|u[a-fA-F0-9]{8}).'
55+ scope: invalid.illeagal.character.string.fsharp
56+ comments:
57+ - match: \(\*\*?(\*)\)
58+ scope: comment.block.fsharp
59+ captures:
60+ 1: comment.block.empty.fsharp
61+ - match: '\(\*[^\)]'
62+ push:
63+ - meta_scope: comment.block.fsharp
64+ - match: \*\)
65+ pop: true
66+ - include: comments
67+ - match: //.*$
68+ scope: comment.line.double-slash.fsharp
69+ constants:
70+ - match: \(\)
71+ scope: constant.language.unit.fsharp
72+ - match: '\b-?[0-9][0-9_]*((\.([0-9][0-9_]*([eE][+-]??[0-9][0-9_]*)?)?)|([eE][+-]??[0-9][0-9_]*))'
73+ scope: constant.numeric.floating-point.fsharp
74+ - match: '\b(-?((0(x|X)[0-9a-fA-F][0-9a-fA-F_]*)|(0(o|O)[0-7][0-7_]*)|(0(b|B)[01][01_]*)|([0-9][0-9_]*)))'
75+ scope: constant.numeric.integer.nativeint.fsharp
76+ definition:
77+ - match: '\b(val|val|let|and|member|override|use)\s?(rec|inline|mutable)?(\s+\(?([a-zA-Z.\|_][a-zA-Z0-9.|_]*)\)?\w*)\b'
78+ captures:
79+ 1: keyword.other.binding.fsharp
80+ 2: keyword.other.function-recursive.fsharp
81+ 3: variable.other.binding.fsharp
82+ push:
83+ - meta_scope: meta.binding.fsharp
84+ - match: "=|$"
85+ captures:
86+ 1: punctuation.separator.function.type-constraint.fsharp
87+ pop: true
88+ - include: variables
89+ - match: \b(let)\s+((\(\))|(_))\s+=
90+ scope: meta.expression.fsharp
91+ captures:
92+ 1: keyword.other.binding.fsharp
93+ 2: keyword.other.function-recursive.fsharp
94+ 4: constant.language.unit.fsharp
95+ 5: constant.language.ignored.fsharp
96+ keywords:
97+ - match: ^\s*#\s*(light|if|else|endif|r|I|load|time|help|quit)\b
98+ push:
99+ - meta_scope: meta.preprocessor.fsharp
100+ - match: (\s|$)
101+ pop: true
102+ - match: \b(new|in|as|if|then|else|elif|for|begin|end|match|with|type|inherit|true|false|null|do)\b
103+ scope: keyword.other.fsharp
104+ - match: '(\|>|\|?>|\->|\<\-|:>|:|\[|\]|\;|\||_)'
105+ scope: entity.name
106+ method_calls:
107+ - match: '(?<!\w)([a-z]\w*)(\.)'
108+ push:
109+ - meta_scope: meta.method-call.fsharp
110+ - match: '[A-Z]\w*(\.)'
111+ scope: meta.method.fsharp
112+ captures:
113+ 1: punctuation.separator.method-call.fsharp
114+ - match: (?=.)
115+ pop: true
116+ modules:
117+ - match: '\b(namespace|module)\s+([a-zA-Z][a-zA-Z0-9''_.]*)'
118+ captures:
119+ 1: keyword.other.fsharp
120+ 2: entity.name.section.fsharp
121+ push:
122+ - meta_scope: meta.module.namespace.fsharp
123+ - match: (\s|$)
124+ pop: true
125+ - match: '(\.)([A-Z][a-zA-Z0-9''_]*)'
126+ scope: support.other.module.fsharp
127+ captures:
128+ 1: punctuation.separator.module-reference.fsharp
129+ 2: support.other.module.fsharp
130+ - match: '\b(open)\s+([A-Z][a-zA-Z0-9''_]*)(?=(\.[A-Z][a-zA-Z0-9_]*)*)'
131+ captures:
132+ 1: keyword.other.fsharp
133+ 2: support.other.module.fsharp
134+ push:
135+ - meta_scope: meta.module.open.fsharp
136+ - match: (\s|$)
137+ pop: true
138+ - match: '(\.)([A-Z][a-zA-Z0-9''_]*)'
139+ scope: support.other.module.fsharp
140+ captures:
141+ 1: punctuation.separator.module-reference.fsharp
142+ 2: support.other.module.fsharp
143+ - match: '^\s*(module)\s+([A-Z][a-zA-Z0-9''_]*)\s*(=)\s*([A-Z][a-zA-Z0-9''_]*)'
144+ captures:
145+ 1: keyword.other.module-definition.fsharp
146+ 2: entity.name.type.module.fsharp
147+ 3: punctuation.separator.module-definition.fsharp
148+ 4: support.other.module.fsharp
149+ push:
150+ - meta_scope: meta.module.alias.fsharp
151+ - match: (\s|$)
152+ pop: true
153+ - match: '(\.)([A-Z][a-zA-Z0-9''_]*)'
154+ scope: support.other.module.fsharp
155+ captures:
156+ 1: punctuation.separator.module-reference.fsharp
157+ 2: support.other.module.fsharp
158+ - match: '(?<!\w)([A-Z][a-zA-Z0-9_]*)(\.)'
159+ captures:
160+ 1: support.other.module.fsharp
161+ 2: punctuation.separator.module-reference.fsharp
162+ push:
163+ - meta_scope: meta.module.reference.fsharp
164+ - match: '[A-Z][a-zA-Z0-9_]+(\.)'
165+ scope: support.other.module.fsharp
166+ captures:
167+ 1: punctuation.separator.module-reference.fsharp
168+ - match: (?=.)
169+ pop: true
170+ strings:
171+ - match: '(?=[^\\])(""")'
172+ captures:
173+ 1: punctuation.definition.string.begin.fsharp
174+ push:
175+ - meta_scope: string.quoted.double.fsharp
176+ - match: (""")
177+ captures:
178+ 1: punctuation.definition.string.end.fsharp
179+ pop: true
180+ - match: '\\$[ \t]*'
181+ scope: punctuation.separator.string.ignore-eol.fsharp
182+ - match: '(?=[^\\])(@")'
183+ captures:
184+ 1: punctuation.definition.string.begin.fsharp
185+ push:
186+ - meta_scope: string.quoted.double.fsharp
187+ - match: (")
188+ captures:
189+ 1: punctuation.definition.string.end.fsharp
190+ pop: true
191+ - match: '\\$[ \t]*'
192+ scope: punctuation.separator.string.ignore-eol.fsharp
193+ - match: '(?=[^\\])(")'
194+ captures:
195+ 1: punctuation.definition.string.begin.fsharp
196+ push:
197+ - meta_scope: string.quoted.double.fsharp
198+ - match: (")
199+ captures:
200+ 1: punctuation.definition.string.end.fsharp
201+ pop: true
202+ - match: '\\$[ \t]*'
203+ scope: punctuation.separator.string.ignore-eol.fsharp
204+ - match: '\\([\\''ntbr]|u[a-fA-F0-9]{4}|u[a-fA-F0-9]{8})'
205+ scope: constant.character.string.escape.fsharp
206+ - match: '\\(?![\\''ntbr]|u[a-fA-F0-9]{4}|u[a-fA-F0-9]{8}).'
207+ scope: invalid.illeagal.character.string.fsharp
208+ - match: '(?=[^\\])('')'
209+ captures:
210+ 1: punctuation.definition.string.begin.fsharp
211+ push:
212+ - meta_scope: string.quoted.double.fsharp
213+ - match: (')
214+ captures:
215+ 1: punctuation.definition.string.end.fsharp
216+ pop: true
217+ - match: '\\$[ \t]*'
218+ scope: punctuation.separator.string.ignore-eol.fsharp
219+ - match: '\\([\\"ntbr]|u[a-fA-F0-9]{4}|u[a-fA-F0-9]{8})'
220+ scope: constant.character.string.escape.fsharp
221+ - match: '\\(?![\\"ntbr]|u[a-fA-F0-9]{4}|u[a-fA-F0-9]{8}).'
222+ scope: invalid.illeagal.character.string.fsharp
223+ structure:
224+ - match: \(
225+ push:
226+ - meta_scope: meta.paren-group.fsharp
227+ - match: \)
228+ pop: true
229+ - include: main
230+ variables:
231+ - match: \(\)
232+ scope: variable.parameter.unit.fsharp
233+ - match: '[a-zA-Z]\w*'
234+ scope: variable.parameter.fsharp