2
2
---
3
3
name : Crontab
4
4
scope : source.crontab
5
+ version : 2
5
6
6
7
file_extensions :
7
8
- tab
@@ -14,10 +15,6 @@ contexts:
14
15
- include : variables
15
16
- include : at-syntax
16
17
- include : cron-syntax
17
- # Don't `invalid.illegal` in-process completions
18
- - match : ' {{snippet_typing}}'
19
- - match : ^\s*\w+
20
- scope : invalid.illegal.crontab
21
18
22
19
# ##[ CRON EXPRESSIONS ]########################################################
23
20
@@ -43,7 +40,7 @@ contexts:
43
40
- meta_content_scope :
44
41
meta.string.cron-expression.crontab
45
42
meta.sequence.cron.minute.crontab
46
- - include : pop-nl
43
+ - include : pop-eol
47
44
- include : illegal-punctuation
48
45
- include : cron-common
49
46
- match : \b{{minute}}(-){{minute}}\b
@@ -52,13 +49,14 @@ contexts:
52
49
1 : punctuation.separator.sequence.crontab
53
50
- match : \b{{minute}}\b
54
51
scope : constant.numeric.integer.decimal.crontab
52
+ - include : illegal-numbers
55
53
- match : (?=[ \t])
56
54
set : cron-hour-is-next
57
55
- include : illegal-non-whitespace
58
56
59
57
cron-hour-is-next :
60
58
- meta_content_scope : meta.string.cron-expression.crontab
61
- - include : pop-nl
59
+ - include : pop-eol
62
60
- include : cron-initial-comma
63
61
- match : (?=\S)
64
62
set : cron-hour
@@ -67,7 +65,7 @@ contexts:
67
65
- meta_content_scope :
68
66
meta.string.cron-expression.crontab
69
67
meta.sequence.cron.hour.crontab
70
- - include : pop-nl
68
+ - include : pop-eol
71
69
- include : illegal-punctuation
72
70
- include : cron-common
73
71
- match : \b{{hour}}(-){{hour}}\b
@@ -76,13 +74,14 @@ contexts:
76
74
1 : punctuation.separator.sequence.crontab
77
75
- match : \b{{hour}}\b
78
76
scope : constant.numeric.integer.decimal.crontab
77
+ - include : illegal-numbers
79
78
- match : (?=[ \t])
80
79
set : cron-day-of-month-is-next
81
80
- include : illegal-non-whitespace
82
81
83
82
cron-day-of-month-is-next :
84
83
- meta_content_scope : meta.string.cron-expression.crontab
85
- - include : pop-nl
84
+ - include : pop-eol
86
85
- include : cron-initial-comma
87
86
- match : (?=\S)
88
87
set : cron-day-of-month
@@ -91,7 +90,7 @@ contexts:
91
90
- meta_content_scope :
92
91
meta.string.cron-expression.crontab
93
92
meta.sequence.cron.day-of-month.crontab
94
- - include : pop-nl
93
+ - include : pop-eol
95
94
- include : illegal-punctuation
96
95
- include : cron-common
97
96
- match : \b{{day_of_month}}(-){{day_of_month}}\b
@@ -102,6 +101,7 @@ contexts:
102
101
captures :
103
102
1 : constant.numeric.integer.decimal.crontab
104
103
2 : invalid.deprecated.non-standard.crontab
104
+ - include : illegal-numbers
105
105
- match : \?
106
106
scope : invalid.deprecated.non-standard.crontab
107
107
- match : (?=[ \t])
@@ -110,7 +110,7 @@ contexts:
110
110
111
111
cron-month-is-next :
112
112
- meta_content_scope : meta.string.cron-expression.crontab
113
- - include : pop-nl
113
+ - include : pop-eol
114
114
- include : cron-initial-comma
115
115
- match : (?=\S)
116
116
set : cron-month
@@ -119,7 +119,7 @@ contexts:
119
119
- meta_content_scope :
120
120
meta.string.cron-expression.crontab
121
121
meta.sequence.cron.month.crontab
122
- - include : pop-nl
122
+ - include : pop-eol
123
123
- include : illegal-punctuation
124
124
- include : cron-common
125
125
- match : \b{{month}}(-){{month}}\b
@@ -128,6 +128,7 @@ contexts:
128
128
1 : punctuation.separator.sequence.crontab
129
129
- match : \b{{month}}\b
130
130
scope : constant.numeric.integer.decimal.crontab
131
+ - include : illegal-numbers
131
132
- match : \b({{words_month}})(-)({{words_month}})\b
132
133
scope : constant.other.range.crontab
133
134
captures :
@@ -138,11 +139,10 @@ contexts:
138
139
scope : support.constant.month-name.crontab
139
140
- match : (?=[ \t])
140
141
set : cron-day-of-week-is-next
141
- - include : illegal-non-alpha
142
142
143
143
cron-day-of-week-is-next :
144
144
- meta_content_scope : meta.string.cron-expression.crontab
145
- - include : pop-nl
145
+ - include : pop-eol
146
146
- include : cron-initial-comma
147
147
- match : (?=\S)
148
148
set : cron-day-of-week
@@ -151,7 +151,7 @@ contexts:
151
151
- meta_content_scope :
152
152
meta.string.cron-expression.crontab
153
153
meta.sequence.cron.day-of-week.crontab
154
- - include : pop-nl
154
+ - include : pop-eol
155
155
- include : illegal-punctuation
156
156
- include : cron-common
157
157
- match : \b{{day_of_week}}(-){{day_of_week}}\b
@@ -162,6 +162,7 @@ contexts:
162
162
captures :
163
163
1 : constant.numeric.integer.decimal.crontab
164
164
2 : invalid.deprecated.non-standard.crontab
165
+ - include : illegal-numbers
165
166
- match : \b({{words_day_of_week}})(-)({{words_day_of_week}})\b
166
167
scope : constant.other.range.crontab
167
168
captures :
@@ -174,22 +175,31 @@ contexts:
174
175
scope : invalid.deprecated.non-standard.crontab
175
176
- match : (?=[ \t])
176
177
set : command-is-next
177
- - include : illegal-non-alpha
178
178
179
179
command-is-next :
180
- - include : pop-nl
180
+ - include : pop-eol
181
181
- match : \s+
182
- embed : scope:source.shell
183
- escape : (?=\n|$)
182
+ embed : scope:source.shell.bash.crontab
183
+ escape : (?=$|(?<!\\)%)
184
+ - match : (?=%)
185
+ set : command-stdin
186
+
187
+ command-stdin :
188
+ - meta_content_scope : meta.string.stdin.crontab string.unquoted.crontab
189
+ - include : pop-eol
190
+ - match : \\%
191
+ scope : constant.character.escape.crontab
192
+ - match : ' %'
193
+ scope : constant.character.newline.crontab
184
194
185
195
at-syntax :
186
196
# Keyword, then script embed
187
197
- match : ^\s*((@){{keywords}})[ \t]+
188
198
captures :
189
199
1 : constant.language.schedule.crontab
190
200
2 : punctuation.definition.variable.crontab
191
- embed : scope:source.shell
192
- escape : $
201
+ embed : scope:source.shell.bash.crontab
202
+ escape : (?=$)
193
203
# Don't unhighlight keywords just because EOL
194
204
- match : ^\s*((@){{keywords}})\b
195
205
captures :
@@ -201,19 +211,7 @@ contexts:
201
211
1 : punctuation.definition.variable.crontab
202
212
2 : meta.completion.at.crontab
203
213
204
- # ##[ MISCELLANEOUS ]###########################################################
205
-
206
- comments :
207
- - match : ^\s*(?=#)
208
- push : comment
209
-
210
- comment :
211
- - match : ' #'
212
- scope : punctuation.definition.comment.crontab
213
- push :
214
- - meta_scope : comment.line.number-sign.crontab
215
- - include : pop-nl
216
- - include : pop-nl
214
+ # ##[ ENVIRONMENT VARIABLES ]###################################################
217
215
218
216
variables :
219
217
- match : ^([a-zA-Z0-9_]+)\s*(=)
@@ -223,33 +221,53 @@ contexts:
223
221
push : variable-value
224
222
225
223
variable-value :
226
- - include : pop-nl
224
+ - include : pop-eol
227
225
- match : ' "'
228
226
scope : punctuation.definition.string.begin.crontab
229
- set :
230
- - meta_scope : string.quoted.double.crontab
231
- - match : ' "'
232
- scope : punctuation.definition.string.end.crontab
233
- pop : true
227
+ set : string-body-double
234
228
- match : " '"
235
229
scope : punctuation.definition.string.begin.crontab
236
- set :
237
- - meta_scope : string.quoted.single.crontab
238
- - match : " '"
239
- scope : punctuation.definition.string.end.crontab
240
- pop : true
230
+ set : string-body-single
241
231
- match : \S
232
+ push : string-body-unquoted
233
+
234
+ string-body-double :
235
+ - meta_scope : meta.string.crontab string.quoted.double.crontab
236
+ - match : ' "'
237
+ scope : punctuation.definition.string.end.crontab
238
+ pop : 1
239
+
240
+ string-body-single :
241
+ - meta_scope : meta.string.crontab string.quoted.single.crontab
242
+ - match : " '"
243
+ scope : punctuation.definition.string.end.crontab
244
+ pop : 1
245
+
246
+ string-body-unquoted :
247
+ - meta_scope : meta.string.crontab string.unquoted.crontab
248
+ - match : (?=\s*$)
249
+ pop : 1
250
+
251
+ # ##[ MISCELLANEOUS ]###########################################################
252
+
253
+ comments :
254
+ - match : ^\s*(?=#)
255
+ push : comment
256
+
257
+ comment :
258
+ - match : ' #'
259
+ scope : punctuation.definition.comment.crontab
242
260
push :
243
- - meta_scope : string.unquoted .crontab
244
- - match : (?=\s*$)
245
- pop : true
261
+ - meta_scope : comment.line.number-sign .crontab
262
+ - include : pop-eol
263
+ - include : pop-eol
246
264
247
265
illegal-punctuation :
248
266
- match : \*{2,}|[/,?-]{2,}|,(?=[ \t])
249
267
scope : invalid.illegal.crontab
250
268
251
- illegal-non-alpha :
252
- - match : (?i:[^a-z\s]+)
269
+ illegal-numbers :
270
+ - match : \d+
253
271
scope : invalid.illegal.crontab
254
272
255
273
illegal-non-whitespace :
@@ -258,9 +276,9 @@ contexts:
258
276
259
277
# ##[ PROTOTYPE ]###############################################################
260
278
261
- pop-nl :
279
+ pop-eol :
262
280
- match : $\n?
263
- pop : true
281
+ pop : 1
264
282
265
283
# ##############################################################################
266
284
0 commit comments