1" Vim syntax file
2" Language:         AutoHotkey script file
3" Maintainer:       Nikolai Weibull <[email protected]>
4" Latest Revision:  2008-06-22
5
6if exists("b:current_syntax")
7  finish
8endif
9
10let s:cpo_save = &cpo
11set cpo&vim
12
13syn case ignore
14
15syn keyword autohotkeyTodo
16      \ contained
17      \ TODO FIXME XXX NOTE
18
19syn cluster autohotkeyCommentGroup
20      \ contains=
21      \   autohotkeyTodo,
22      \   @Spell
23
24syn match   autohotkeyComment
25      \ display
26      \ contains=@autohotkeyCommentGroup
27      \ '`\@<!;.*$'
28
29syn region  autohotkeyComment
30      \ contains=@autohotkeyCommentGroup
31      \ matchgroup=autohotkeyCommentStart
32      \ start='/\*'
33      \ end='\*/'
34
35syn match   autohotkeyEscape
36      \ display
37      \ '`.'
38
39syn match   autohotkeyHotkey
40      \ contains=autohotkeyKey,
41      \   autohotkeyHotkeyDelimiter
42      \ display
43      \ '^.\{-}::'
44
45syn match   autohotkeyKey
46      \ contained
47      \ display
48      \ '^.\{-}'
49
50syn match   autohotkeyDelimiter
51      \ contained
52      \ display
53      \ '::'
54
55syn match   autohotkeyHotstringDefinition
56      \ contains=autohotkeyHotstring,
57      \   autohotkeyHotstringDelimiter
58      \ display
59      \ '^:\%(B0\|C1\|K\d\+\|P\d\+\|S[IPE]\|Z\d\=\|[*?COR]\)*:.\{-}::'
60
61syn match   autohotkeyHotstring
62      \ contained
63      \ display
64      \ '.\{-}'
65
66syn match   autohotkeyHotstringDelimiter
67      \ contained
68      \ display
69      \ '::'
70
71syn match   autohotkeyHotstringDelimiter
72      \ contains=autohotkeyHotstringOptions
73      \ contained
74      \ display
75      \ ':\%(B0\|C1\|K\d\+\|P\d\+\|S[IPE]\|Z\d\=\|[*?COR]\):'
76
77syn match   autohotkeyHotstringOptions
78      \ contained
79      \ display
80      \ '\%(B0\|C1\|K\d\+\|P\d\+\|S[IPE]\|Z\d\=\|[*?COR]\)'
81
82syn region autohotkeyString
83      \ display
84      \ oneline
85      \ matchgroup=autohotkeyStringDelimiter
86      \ start=+"+
87      \ end=+"+
88      \ contains=autohotkeyEscape
89
90syn region autohotkeyVariable
91      \ display
92      \ oneline
93      \ contains=autohotkeyBuiltinVariable
94      \ matchgroup=autohotkeyVariableDelimiter
95      \ start="%"
96      \ end="%"
97      \ keepend
98
99syn keyword autohotkeyBuiltinVariable
100      \ A_Space A_Tab
101      \ A_WorkingDir A_ScriptDir A_ScriptName A_ScriptFullPath A_LineNumber
102      \ A_LineFile A_AhkVersion A_AhkPAth A_IsCompiled A_ExitReason
103      \ A_YYYY A_MM A_DD A_MMMM A_MMM A_DDDD A_DDD A_WDay A_YWeek A_Hour A_Min
104      \ A_Sec A_MSec A_Now A_NowUTC A_TickCount
105      \ A_IsSuspended A_BatchLines A_TitleMatchMode A_TitleMatchModeSpeed
106      \ A_DetectHiddenWindows A_DetectHiddenText A_AutoTrim A_STringCaseSense
107      \ A_FormatInteger A_FormatFloat A_KeyDelay A_WinDelay A_ControlDelay
108      \ A_MouseDelay A_DefaultMouseSpeed A_IconHidden A_IconTip A_IconFile
109      \ A_IconNumber
110      \ A_TimeIdle A_TimeIdlePhysical
111      \ A_Gui A_GuiControl A_GuiWidth A_GuiHeight A_GuiX A_GuiY A_GuiEvent
112      \ A_GuiControlEvent A_EventInfo
113      \ A_ThisMenuItem A_ThisMenu A_ThisMenuItemPos A_ThisHotkey A_PriorHotkey
114      \ A_TimeSinceThisHotkey A_TimeSincePriorHotkey A_EndChar
115      \ ComSpec A_Temp A_OSType A_OSVersion A_Language A_ComputerName A_UserName
116      \ A_WinDir A_ProgramFiles ProgramFiles A_AppData A_AppDataCommon A_Desktop
117      \ A_DesktopCommon A_StartMenu A_StartMenuCommon A_Programs
118      \ A_ProgramsCommon A_Startup A_StartupCommon A_MyDocuments A_IsAdmin
119      \ A_ScreenWidth A_ScreenHeight A_IPAddress1 A_IPAddress2 A_IPAddress3
120      \ A_IPAddress4
121      \ A_Cursor A_CaretX A_CaretY Clipboard ClipboardAll ErrorLevel A_LastError
122      \ A_Index A_LoopFileName A_LoopRegName A_LoopReadLine A_LoopField
123
124syn match   autohotkeyBuiltinVariable
125      \ contained
126      \ display
127      \ '%\d\+%'
128
129syn keyword autohotkeyCommand
130      \ ClipWait EnvGet EnvSet EnvUpdate
131      \ Drive DriveGet DriveSpaceFree FileAppend FileCopy FileCopyDir
132      \ FileCreateDir FileCreateShortcut FileDelete FileGetAttrib
133      \ FileGetShortcut FileGetSize FileGetTime FileGetVersion FileInstall
134      \ FileMove FileMoveDir FileReadLine FileRead FileRecycle FileRecycleEmpty
135      \ FileRemoveDir FileSelectFolder FileSelectFile FileSetAttrib FileSetTime
136      \ IniDelete IniRead IniWrite SetWorkingDir
137      \ SplitPath
138      \ Gui GuiControl GuiControlGet IfMsgBox InputBox MsgBox Progress
139      \ SplashImage SplashTextOn SplashTextOff ToolTip TrayTip
140      \ Hotkey ListHotkeys BlockInput ControlSend ControlSendRaw GetKeyState
141      \ KeyHistory KeyWait Input Send SendRaw SendInput SendPlay SendEvent
142      \ SendMode SetKeyDelay SetNumScrollCapsLockState SetStoreCapslockMode
143      \ EnvAdd EnvDiv EnvMult EnvSub Random SetFormat Transform
144      \ AutoTrim BlockInput CoordMode Critical Edit ImageSearch
145      \ ListLines ListVars Menu OutputDebug PixelGetColor PixelSearch
146      \ SetBatchLines SetEnv SetTimer SysGet Thread Transform URLDownloadToFile
147      \ Click ControlClick MouseClick MouseClickDrag MouseGetPos MouseMove
148      \ SetDefaultMouseSpeed SetMouseDelay
149      \ Process Run RunWait RunAs Shutdown Sleep
150      \ RegDelete RegRead RegWrite
151      \ SoundBeep SoundGet SoundGetWaveVolume SoundPlay SoundSet
152      \ SoundSetWaveVolume
153      \ FormatTime IfInString IfNotInString Sort StringCaseSense StringGetPos
154      \ StringLeft StringRight StringLower StringUpper StringMid StringReplace
155      \ StringSplit StringTrimLeft StringTrimRight
156      \ Control ControlClick ControlFocus ControlGet ControlGetFocus
157      \ ControlGetPos ControlGetText ControlMove ControlSend ControlSendRaw
158      \ ControlSetText Menu PostMessage SendMessage SetControlDelay
159      \ WinMenuSelectItem GroupActivate GroupAdd GroupClose GroupDeactivate
160      \ DetectHiddenText DetectHiddenWindows SetTitleMatchMode SetWinDelay
161      \ StatusBarGetText StatusBarWait WinActivate WinActivateBottom WinClose
162      \ WinGet WinGetActiveStats WinGetActiveTitle WinGetClass WinGetPos
163      \ WinGetText WinGetTitle WinHide WinKill WinMaximize WinMinimize
164      \ WinMinimizeAll WinMinimizeAllUndo WinMove WinRestore WinSet
165      \ WinSetTitle WinShow WinWait WinWaitActive WinWaitNotActive WinWaitClose
166
167syn keyword autohotkeyFunction
168      \ InStr RegExMatch RegExReplace StrLen SubStr Asc Chr
169      \ DllCall VarSetCapacity WinActive WinExist IsLabel OnMessage
170      \ Abs Ceil Exp Floor Log Ln Mod Round Sqrt Sin Cos Tan ASin ACos ATan
171      \ FileExist GetKeyState
172
173syn keyword autohotkeyStatement
174      \ Break Continue Exit ExitApp Gosub Goto OnExit Pause Return
175      \ Suspend Reload
176
177syn keyword autohotkeyRepeat
178      \ Loop
179
180syn keyword autohotkeyConditional
181      \ IfExist IfNotExist If IfEqual IfLess IfGreater Else
182
183syn match   autohotkeyPreProcStart
184      \ nextgroup=
185      \   autohotkeyInclude,
186      \   autohotkeyPreProc
187      \ skipwhite
188      \ display
189      \ '^\s*\zs#'
190
191syn keyword autohotkeyInclude
192      \ contained
193      \ Include
194      \ IncludeAgain
195
196syn keyword autohotkeyPreProc
197      \ contained
198      \ HotkeyInterval HotKeyModifierTimeout
199      \ Hotstring
200      \ IfWinActive IfWinNotActive IfWinExist IfWinNotExist
201      \ MaxHotkeysPerInterval MaxThreads MaxThreadsBuffer MaxThreadsPerHotkey
202      \ UseHook InstallKeybdHook InstallMouseHook
203      \ KeyHistory
204      \ NoTrayIcon SingleInstance
205      \ WinActivateForce
206      \ AllowSameLineComments
207      \ ClipboardTimeout
208      \ CommentFlag
209      \ ErrorStdOut
210      \ EscapeChar
211      \ MaxMem
212      \ NoEnv
213      \ Persistent
214
215syn keyword autohotkeyMatchClass
216      \ ahk_group ahk_class ahk_id ahk_pid
217
218syn match   autohotkeyNumbers
219      \ display
220      \ transparent
221      \ contains=
222      \   autohotkeyInteger,
223      \   autohotkeyFloat
224      \ '\<\d\|\.\d'
225
226syn match   autohotkeyInteger
227      \ contained
228      \ display
229      \ '\d\+\>'
230
231syn match   autohotkeyInteger
232      \ contained
233      \ display
234      \ '0x\x\+\>'
235
236syn match   autohotkeyFloat
237      \ contained
238      \ display
239      \ '\d\+\.\d*\|\.\d\+\>'
240
241syn keyword autohotkeyType
242      \ local
243      \ global
244
245syn keyword autohotkeyBoolean
246      \ true
247      \ false
248
249" TODO: Shouldn't we look for g:, b:,  variables before defaulting to
250" something?
251if exists("g:autohotkey_syntax_sync_minlines")
252  let b:autohotkey_syntax_sync_minlines = g:autohotkey_syntax_sync_minlines
253else
254  let b:autohotkey_syntax_sync_minlines = 50
255endif
256exec "syn sync ccomment autohotkeyComment minlines=" . b:autohotkey_syntax_sync_minlines
257
258hi def link autohotkeyTodo                Todo
259hi def link autohotkeyComment             Comment
260hi def link autohotkeyCommentStart        autohotkeyComment
261hi def link autohotkeyEscape              Special
262hi def link autohotkeyHotkey              Type
263hi def link autohotkeyKey                 Type
264hi def link autohotkeyDelimiter           Delimiter
265hi def link autohotkeyHotstringDefinition Type
266hi def link autohotkeyHotstring           Type
267hi def link autohotkeyHotstringDelimiter  autohotkeyDelimiter
268hi def link autohotkeyHotstringOptions    Special
269hi def link autohotkeyString              String
270hi def link autohotkeyStringDelimiter     autohotkeyString
271hi def link autohotkeyVariable            Identifier
272hi def link autohotkeyVariableDelimiter   autohotkeyVariable
273hi def link autohotkeyBuiltinVariable     Macro
274hi def link autohotkeyCommand             Keyword
275hi def link autohotkeyFunction            Function
276hi def link autohotkeyStatement           autohotkeyCommand
277hi def link autohotkeyRepeat              Repeat
278hi def link autohotkeyConditional         Conditional
279hi def link autohotkeyPreProcStart        PreProc
280hi def link autohotkeyInclude             Include
281hi def link autohotkeyPreProc             PreProc
282hi def link autohotkeyMatchClass          Typedef
283hi def link autohotkeyNumber              Number
284hi def link autohotkeyInteger             autohotkeyNumber
285hi def link autohotkeyFloat               autohotkeyNumber
286hi def link autohotkeyType                Type
287hi def link autohotkeyBoolean             Boolean
288
289let b:current_syntax = "autohotkey"
290
291let &cpo = s:cpo_save
292unlet s:cpo_save
293