Skip to content

Commit de89df2

Browse files
committed
Refactor for more BSD options
1 parent 29c4536 commit de89df2

File tree

2 files changed

+26
-28
lines changed

2 files changed

+26
-28
lines changed

Crontab.sublime-syntax

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,13 @@ contexts:
129129
- match: \b{{month}}\b
130130
scope: constant.numeric.integer.decimal.crontab
131131
- include: illegal-numbers
132-
- match: \b({{words_month}})(-)({{words_month}})\b
132+
- match: ({{words_month}})(-)({{words_month}})
133133
scope: constant.other.range.crontab
134134
captures:
135135
1: support.constant.month-name.crontab
136136
2: punctuation.separator.sequence.crontab
137137
3: support.constant.month-name.crontab
138-
- match: \b{{words_month}}\b
138+
- match: '{{words_month}}'
139139
scope: support.constant.month-name.crontab
140140
- match: (?=[ \t])
141141
set: cron-day-of-week-is-next
@@ -158,18 +158,18 @@ contexts:
158158
scope: constant.other.range.crontab
159159
captures:
160160
1: punctuation.separator.sequence.crontab
161-
- match: \b({{day_of_week}})(L)?\b
161+
- match: ({{day_of_week}})(L)?\b
162162
captures:
163163
1: constant.numeric.integer.decimal.crontab
164164
2: invalid.deprecated.non-standard.crontab
165165
- include: illegal-numbers
166-
- match: \b({{words_day_of_week}})(-)({{words_day_of_week}})\b
166+
- match: ({{words_day_of_week}})(-)({{words_day_of_week}})
167167
scope: constant.other.range.crontab
168168
captures:
169169
1: support.constant.day-of-week-name.crontab
170170
2: punctuation.separator.sequence.crontab
171171
3: support.constant.day-of-week-name.crontab
172-
- match: \b{{words_day_of_week}}\b
172+
- match: '{{words_day_of_week}}'
173173
scope: support.constant.day-of-week-name.crontab
174174
- match: \?|#
175175
scope: invalid.deprecated.non-standard.crontab
@@ -193,18 +193,18 @@ contexts:
193193
scope: constant.character.newline.crontab
194194

195195
at-syntax:
196-
# Keyword, then script embed
197-
- match: ^\s*((@){{keywords}})[ \t]+
196+
# Every X seconds
197+
- match: ^\s*(@)(\d+)(?=[ \t])
198198
captures:
199-
1: constant.language.schedule.crontab
200-
2: punctuation.definition.variable.crontab
201-
embed: scope:source.shell.bash.crontab
202-
escape: (?=$)
203-
# Don't unhighlight keywords just because EOL
204-
- match: ^\s*((@){{keywords}})\b
199+
1: punctuation.definition.variable.crontab
200+
2: meta.number.integer.decimal.crontab constant.numeric.value.crontab
201+
set: command-is-next
202+
# Keyword, then script embed
203+
- match: ^\s*((@){{keywords}})(?=[ \t])
205204
captures:
206205
1: constant.language.schedule.crontab
207206
2: punctuation.definition.variable.crontab
207+
set: command-is-next
208208
# Set up autocomplete for keywords
209209
- match: ^\s*(@)(\w*(?:[\n\s]|$))
210210
captures:
@@ -288,18 +288,11 @@ variables:
288288
day_of_month: (?:[1-9]|[1-2]\d|3[01]) # 1-31
289289
month: (?:[1-9]|1[0-2]) # 1-12
290290
day_of_week: (?:[0-7]) # 0-7
291-
words_month: (?i:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)
292-
words_day_of_week: (?i:Sun|Mon|Tue|Wed|Thu|Fri|Sat)
293-
keywords: (?:reboot|yearly|annually|monthly|weekly|daily|midnight|hourly)
294-
snippet_typing: |-
295-
(?x:
296-
c(?:r(?:o(?:n)?)?)?
297-
| r(?:e(?:b(?:o(?:o(?:t)?)?)?)?)?
298-
| y(?:e(?:a(?:r(?:l(?:y)?)?)?)?)?
299-
| a(?:n(?:n(?:u(?:a(?:l(?:l(?:y)?)?)?)?)?)?)?
300-
| m(?:o(?:n(?:t(?:h(?:l(?:y)?)?)?)?)?)?
301-
| w(?:e(?:e(?:k(?:l(?:y)?)?)?)?)?
302-
| d(?:a(?:i(?:l(?:y)?)?)?)?
303-
| m(?:i(?:d(?:n(?:i(?:g(?:h(?:t)?)?)?)?)?)?)?
304-
| h(?:o(?:u(?:r(?:l(?:y)?)?)?)?)?
305-
)
291+
words_month: \b(?i:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\b
292+
words_day_of_week: \b(?i:Sun|Mon|Tue|Wed|Thu|Fri|Sat)\b
293+
keywords: |-
294+
\b(?x:
295+
reboot | yearly | annually | monthly | weekly | daily | hourly
296+
# BSD extras
297+
| midnight | every_minute | every_second
298+
)\b

tests/syntax_test_jobs.crontab

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ SHELL=/bin/sh
6868
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source source
6969
# ^ - source source
7070

71+
@300 echo run this repeatedly, every 300 seconds after execution finishes
72+
#^^^ meta.number.integer.decimal.crontab constant.numeric.value.crontab
73+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source source
74+
# ^^^^ meta.function-call.identifier.shell support.function.shell
75+
7176
#m h dom mon dow command
7277
59 * * * * sleep 10; /run/with/spacing && /run/if/spacing
7378
# <- meta.string.cron-expression

0 commit comments

Comments
 (0)