summaryrefslogtreecommitdiffstats
path: root/syntax/applescript.vim
blob: 2e72959efa9e07d2bd3f1cee0e13442c23bcd8b1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
if has_key(g:polyglot_is_disabled, 'applescript')
  finish
endif

" Vim syntax file
" Language:    AppleScript
" Maintainer:  Jim Eberle <jim.eberle@fastnlight.com>
" Last Change: Mar 18, 2010
" URL:         http://www.fastnlight.com/syntax/applescript.vim

" Use :syn w/in a buffer to see language element breakdown

if version < 600
  syntax clear
elseif exists("b:current_syntax")
  finish
endif

" --- Statement ---
syn keyword scptStmt get set count copy run global local prop property
syn keyword scptStmt close put delete duplicate exists
syn keyword scptStmt launch open print quit make move reopen save
syn keyword scptStmt saving into
hi def link scptStmt Statement

" --- Type ---
syn keyword scptType text string number integer real color date
hi def link scptType Type

" --- Operator ---
syn keyword scptOp div mod not and or as
syn match   scptOp "[-+*/^&]"
" MacRoman single char :- (divide)
exec 'syn match scptOp "'.nr2char(214).'"'
syn match scptOp "\<\(a \)\?\(ref\( to\)\?\|reference to\)\>"
hi def link scptOp Operator

" Containment
syn match   scptIN "\<starts\? with\>"
syn match   scptIN "\<begins\? with\>"
syn match   scptIN "\<ends\? with\>"
syn match   scptIN "\<contains\>"
syn match   scptIN "\<does not contain\>"
syn match   scptIN "\<doesn't contain\>"
syn match   scptIN "\<is in\>"
syn match   scptIN "\<is contained by\>"
syn match   scptIN "\<is not in\>"
syn match   scptIN "\<is not contained by\>"
syn match   scptIN "\<isn't contained by\>"
hi def link scptIN scptOp

" Equals
syn match   scptEQ "="
syn match   scptEQ "\<equal\>"
syn match   scptEQ "\<equals\>"
syn match   scptEQ "\<equal to\>"
syn match   scptEQ "\<is\>"
syn match   scptEQ "\<is equal to\>"
hi def link scptEQ scptOp

" Not Equals
syn match   scptNE "\<does not equal\>"
syn match   scptNE "\<doesn't equal\>"
syn match   scptNE "\<is not\>"
syn match   scptNE "\<is not equal\( to\)\?\>"
syn match   scptNE "\<isn't\>"
syn match   scptNE "\<isn't equal\( to\)\?\>"
hi def link scptNE scptOp
" MacRoman single char /=
exec 'syn match scptNE "'.nr2char(173).'"'

" Less Than
syn match   scptLT "<"
syn match   scptLT "\<comes before\>"
syn match   scptLT "\(is \)\?less than"
syn match   scptLT "\<is not greater than or equal\( to\)\?\>"
syn match   scptLT "\<isn't greater than or equal\( to\)\?\>"
hi def link scptLT scptOp

" Greater Than
syn match   scptGT ">"
syn match   scptGT "\<comes after\>"
syn match   scptGT "\(is \)\?greater than"
syn match   scptGT "\<is not less than or equal\( to\)\?\>"
syn match   scptGT "\<isn't less than or equal\( to\)\?\>"
hi def link scptGT scptOp

" Less Than or Equals
syn match   scptLE "<="
syn match   scptLE "\<does not come after\>"
syn match   scptLE "\<doesn't come after\>"
syn match   scptLE "\(is \)\?less than or equal\( to\)\?"
syn match   scptLE "\<is not greater than\>"
syn match   scptLE "\<isn't greater than\>"
hi def link scptLE scptOp
" MacRoman single char <=
exec 'syn match scptLE "'.nr2char(178).'"'

" Greater Than or Equals
syn match   scptGE ">="
syn match   scptGE "\<does not come before\>"
syn match   scptGE "\<doesn't come before\>"
syn match   scptGE "\(is \)\?greater than or equal\( to\)\?"
syn match   scptGE "\<is not less than\>"
syn match   scptGE "\<isn't less than\>"
hi def link scptGE scptOp
" MacRoman single char >=
exec 'syn match scptGE "'.nr2char(179).'"'

" --- Constant String ---
syn region  scptString start=+"+ skip=+\\\\\|\\"+ end=+"+
hi def link scptString String

" --- Constant Number ---
syn match   scptNumber "\<-\?\d\+\>"
hi def link scptNumber Number

" --- Constant Float ---
syn match   scptFloat display contained "\d\+\.\d*\(e[-+]\=\d\+\)\="
syn match   scptFloat display contained "\.\d\+\(e[-+]\=\d\+\)\=\>"
syn match   scptFloat display contained "\d\+e[-+]\>"
hi def link scptFloat Float

" --- Constant Boolean ---
syn keyword scptBoolean true false yes no ask
hi def link scptBoolean Boolean

" --- Other Constants ---
syn keyword scptConst it me version pi result space tab anything
syn match   scptConst "\<missing value\>"

" Considering and Ignoring
syn match   scptConst "\<application responses\>"
syn match   scptConst "\<current application\>"
syn match   scptConst "\<white space\>"
syn keyword scptConst case diacriticals expansion hyphens punctuation
hi def link scptConst Constant

" Style
syn match   scptStyle "\<all caps\>"
syn match   scptStyle "\<all lowercase\>"
syn match   scptStyle "\<small caps\>"
syn keyword scptStyle bold condensed expanded hidden italic outline plain
syn keyword scptStyle shadow strikethrough subscript superscript underline
hi def link scptStyle scptConst

" Day
syn keyword scptDay Mon Tue Wed Thu Fri Sat Sun
syn keyword scptDay Monday Tuesday Wednesday Thursday Friday Saturday Sunday
syn keyword scptDay weekday
hi def link scptDay scptConst

" Month
syn keyword scptMonth Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
syn keyword scptMonth January February March
syn keyword scptMonth April May June
syn keyword scptMonth July August September
syn keyword scptMonth October November December
syn keyword scptMonth month
hi def link scptMonth scptConst

" Time
syn keyword scptTime minutes hours days weeks
hi def link scptTime scptConstant

" --- Conditional ---
syn keyword scptCond if then else
syn match   scptCond "\<end if\>"
hi def link scptCond Conditional

" --- Repeat ---
syn keyword scptRepeat repeat with from to by continue 
syn match   scptRepeat "\<repeat while\>"
syn match   scptRepeat "\<repeat until\>"
syn match   scptRepeat "\<repeat with\>"
syn match   scptRepeat "\<end repeat\>"
hi def link scptRepeat Repeat

" --- Exception ---
syn keyword scptException try error
syn match   scptException "\<on error\>"
syn match   scptException "\<end try\>"
syn match   scptException "\<end error\>"
hi def link scptException Exception

" --- Keyword ---
syn keyword scptKeyword end tell times exit 
syn keyword scptKeyword application file alias activate
syn keyword scptKeyword script on return without given
syn keyword scptKeyword considering ignoring items delimiters
syn keyword scptKeyword some each every whose where id index item its
syn keyword scptKeyword first second third fourth fifth sixth seventh
syn keyword scptKeyword eighth ninth tenth container
syn match   scptKeyword "\d\+\(st\|nd\|rd\|th\)"
syn keyword scptKeyword last front back middle named thru through
syn keyword scptKeyword before after in of the
syn match   scptKeyword "\<text \>"
syn match   scptKeyword "\<partial result\>"
syn match   scptKeyword "\<but ignoring\>"
syn match   scptKeyword "\<but considering\>"
syn match   scptKeyword "\<with timeout\>"
syn match   scptKeyword "\<with transaction\>"
syn match   scptKeyword "\<do script\>"
syn match   scptKeyword "\<POSIX path\>"
syn match   scptKeyword "\<quoted form\>"
syn match   scptKeyword "'s"
hi def link scptKeyword Keyword

" US Units
syn keyword scptUnitUS quarts gallons ounces pounds inches feet yards miles
syn match   scptUnitUS "\<square feet\>"
syn match   scptUnitUS "\<square yards\>"
syn match   scptUnitUS "\<square miles\>"
syn match   scptUnitUS "\<cubic inches\>"
syn match   scptUnitUS "\<cubic feet\>"
syn match   scptUnitUS "\<cubic yards\>"
syn match   scptUnitUS "\<degrees Fahrenheit\>"
hi def link scptUnitUS scptKey

" British Units
syn keyword scptUnitBT litres centimetres metres kilometres
syn match   scptUnitBT "\<square metres\>"
syn match   scptUnitBT "\<square kilometres\>"
syn match   scptUnitBT "\<cubic centimetres\>"
syn match   scptUnitBT "\<cubic metres\>"
hi def link scptUnitBT scptKey

" Metric Units
syn keyword scptUnitMT liters centimeters meters kilometers grams kilograms 
syn match   scptUnitMT "\<square meters\>"
syn match   scptUnitMT "\<square kilometers\>"
syn match   scptUnitMT "\<cubic centimeters\>"
syn match   scptUnitMT "\<cubic meters\>"
syn match   scptUnitMT "\<degrees Celsius\>"
syn match   scptUnitMT "\<degrees Kelvin\>"
hi def link scptUnitMT scptKey

" --- Comment ---
syn match   scptComment "--.*"
syn match   scptComment "#.*"
syn region  scptComment start="(\*" end="\*)"
hi def link scptComment Comment

" --- Todo ---
syn keyword scptTodo contained TODO FIXME XXX
hi def link scptTodo Todo

let b:current_syntax = "applescript"