blob: c6a68f7a2171a53aed0611f6fc4f185332bc2392 [file] [log] [blame]
Bram Moolenaarb6799ac2007-05-10 16:44:05 +00001" Vim syntax file
2" Language: AutoHotkey script file
Bram Moolenaar690afe12017-01-28 18:34:47 +01003" Maintainer: Michael Wong
4" https://github.com/mmikeww/autohotkey.vim
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +02005" Latest Revision: 2017-04-03
Bram Moolenaar690afe12017-01-28 18:34:47 +01006" Previous Maintainers: SungHyun Nam <goweol@gmail.com>
7" Nikolai Weibull <now@bitwi.se>
Bram Moolenaarb6799ac2007-05-10 16:44:05 +00008
9if exists("b:current_syntax")
10 finish
11endif
12
13let s:cpo_save = &cpo
14set cpo&vim
15
16syn case ignore
17
18syn keyword autohotkeyTodo
19 \ contained
20 \ TODO FIXME XXX NOTE
21
Bram Moolenaar690afe12017-01-28 18:34:47 +010022" only these chars are valid as escape sequences: ,%`;nrbtvaf
23" https://autohotkey.com/docs/commands/_EscapeChar.htm
Bram Moolenaarb6799ac2007-05-10 16:44:05 +000024syn match autohotkeyEscape
25 \ display
Bram Moolenaar690afe12017-01-28 18:34:47 +010026 \ '`[,%`;nrbtvaf]'
Bram Moolenaarb6799ac2007-05-10 16:44:05 +000027
28syn region autohotkeyString
29 \ display
30 \ oneline
31 \ matchgroup=autohotkeyStringDelimiter
32 \ start=+"+
33 \ end=+"+
34 \ contains=autohotkeyEscape
35
Bram Moolenaar690afe12017-01-28 18:34:47 +010036syn match autohotkeyVariable
Bram Moolenaarb6799ac2007-05-10 16:44:05 +000037 \ display
38 \ oneline
39 \ contains=autohotkeyBuiltinVariable
Bram Moolenaarb6799ac2007-05-10 16:44:05 +000040 \ keepend
Bram Moolenaar690afe12017-01-28 18:34:47 +010041 \ '%\S\{-}%'
Bram Moolenaarb6799ac2007-05-10 16:44:05 +000042
43syn keyword autohotkeyBuiltinVariable
44 \ A_Space A_Tab
Bram Moolenaar690afe12017-01-28 18:34:47 +010045 \ A_WorkingDir A_ScriptDir A_ScriptName A_ScriptFullPath A_ScriptHwnd A_LineNumber
46 \ A_LineFile A_ThisFunc A_ThisLabel A_AhkVersion A_AhkPath A_IsUnicode A_IsCompiled A_ExitReason
47 \ A_YYYY A_MM A_DD A_MMMM A_MMM A_DDDD A_DDD A_WDay A_YDay A_YWeek A_Hour A_Min
48 \ A_Mon A_Year A_MDay A_NumBatchLines
Bram Moolenaarb6799ac2007-05-10 16:44:05 +000049 \ A_Sec A_MSec A_Now A_NowUTC A_TickCount
Bram Moolenaar690afe12017-01-28 18:34:47 +010050 \ A_IsSuspended A_IsPaused A_IsCritical A_BatchLines A_TitleMatchMode A_TitleMatchModeSpeed
51 \ A_DetectHiddenWindows A_DetectHiddenText A_AutoTrim A_StringCaseSense
52 \ A_FileEncoding A_FormatInteger A_FormatFloat A_KeyDelay A_WinDelay A_ControlDelay
53 \ A_SendMode A_SendLevel A_StoreCapsLockMode A_KeyDelay A_KeyDelayDuration
54 \ A_KeyDelayPlay A_KeyDelayPlayDuration A_MouseDelayPlay
55 \ A_MouseDelay A_DefaultMouseSpeed A_RegView A_IconHidden A_IconTip A_IconFile
56 \ A_CoordModeToolTip A_CoordModePixel A_CoordModeMouse A_CoordModeCaret A_CoordModeMenu
Bram Moolenaarb6799ac2007-05-10 16:44:05 +000057 \ A_IconNumber
Bram Moolenaar690afe12017-01-28 18:34:47 +010058 \ A_TimeIdle A_TimeIdlePhysical A_DefaultGui A_DefaultListView A_DefaultTreeView
Bram Moolenaarb6799ac2007-05-10 16:44:05 +000059 \ A_Gui A_GuiControl A_GuiWidth A_GuiHeight A_GuiX A_GuiY A_GuiEvent
60 \ A_GuiControlEvent A_EventInfo
61 \ A_ThisMenuItem A_ThisMenu A_ThisMenuItemPos A_ThisHotkey A_PriorHotkey
Bram Moolenaar690afe12017-01-28 18:34:47 +010062 \ A_PriorKey A_TimeSinceThisHotkey A_TimeSincePriorHotkey A_EndChar
Bram Moolenaarb6799ac2007-05-10 16:44:05 +000063 \ ComSpec A_Temp A_OSType A_OSVersion A_Language A_ComputerName A_UserName
Bram Moolenaar690afe12017-01-28 18:34:47 +010064 \ A_Is64BitOS A_PtrSize
Bram Moolenaarb6799ac2007-05-10 16:44:05 +000065 \ A_WinDir A_ProgramFiles ProgramFiles A_AppData A_AppDataCommon A_Desktop
66 \ A_DesktopCommon A_StartMenu A_StartMenuCommon A_Programs
67 \ A_ProgramsCommon A_Startup A_StartupCommon A_MyDocuments A_IsAdmin
Bram Moolenaar690afe12017-01-28 18:34:47 +010068 \ A_ScreenWidth A_ScreenHeight A_ScreenDPI A_IPAddress1 A_IPAddress2 A_IPAddress3
Bram Moolenaarb6799ac2007-05-10 16:44:05 +000069 \ A_IPAddress4
70 \ A_Cursor A_CaretX A_CaretY Clipboard ClipboardAll ErrorLevel A_LastError
71 \ A_Index A_LoopFileName A_LoopRegName A_LoopReadLine A_LoopField
Bram Moolenaar690afe12017-01-28 18:34:47 +010072 \ A_LoopFileExt A_LoopFileFullPath A_LoopFileLongPath A_LoopFileShortPath
73 \ A_LoopFileShortName A_LoopFileDir A_LoopFileTimeModified A_LoopFileTimeCreated
74 \ A_LoopFileTimeAccessed A_LoopFileAttrib A_LoopFileSize A_LoopFileSizeKB A_LoopFileSizeMB
75 \ A_LoopRegType A_LoopRegKey A_LoopRegSubKey A_LoopRegTimeModified
Bram Moolenaarb6799ac2007-05-10 16:44:05 +000076
77syn match autohotkeyBuiltinVariable
78 \ contained
79 \ display
80 \ '%\d\+%'
81
82syn keyword autohotkeyCommand
83 \ ClipWait EnvGet EnvSet EnvUpdate
84 \ Drive DriveGet DriveSpaceFree FileAppend FileCopy FileCopyDir
Bram Moolenaar690afe12017-01-28 18:34:47 +010085 \ FileCreateDir FileCreateShortcut FileDelete FileGetAttrib FileEncoding
Bram Moolenaarb6799ac2007-05-10 16:44:05 +000086 \ FileGetShortcut FileGetSize FileGetTime FileGetVersion FileInstall
87 \ FileMove FileMoveDir FileReadLine FileRead FileRecycle FileRecycleEmpty
88 \ FileRemoveDir FileSelectFolder FileSelectFile FileSetAttrib FileSetTime
89 \ IniDelete IniRead IniWrite SetWorkingDir
90 \ SplitPath
91 \ Gui GuiControl GuiControlGet IfMsgBox InputBox MsgBox Progress
92 \ SplashImage SplashTextOn SplashTextOff ToolTip TrayTip
93 \ Hotkey ListHotkeys BlockInput ControlSend ControlSendRaw GetKeyState
94 \ KeyHistory KeyWait Input Send SendRaw SendInput SendPlay SendEvent
95 \ SendMode SetKeyDelay SetNumScrollCapsLockState SetStoreCapslockMode
96 \ EnvAdd EnvDiv EnvMult EnvSub Random SetFormat Transform
97 \ AutoTrim BlockInput CoordMode Critical Edit ImageSearch
98 \ ListLines ListVars Menu OutputDebug PixelGetColor PixelSearch
99 \ SetBatchLines SetEnv SetTimer SysGet Thread Transform URLDownloadToFile
100 \ Click ControlClick MouseClick MouseClickDrag MouseGetPos MouseMove
101 \ SetDefaultMouseSpeed SetMouseDelay
102 \ Process Run RunWait RunAs Shutdown Sleep
103 \ RegDelete RegRead RegWrite
104 \ SoundBeep SoundGet SoundGetWaveVolume SoundPlay SoundSet
105 \ SoundSetWaveVolume
106 \ FormatTime IfInString IfNotInString Sort StringCaseSense StringGetPos
107 \ StringLeft StringRight StringLower StringUpper StringMid StringReplace
Bram Moolenaar690afe12017-01-28 18:34:47 +0100108 \ StringSplit StringTrimLeft StringTrimRight StringLen
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +0200109 \ StrSplit StrReplace Throw
Bram Moolenaarb6799ac2007-05-10 16:44:05 +0000110 \ Control ControlClick ControlFocus ControlGet ControlGetFocus
111 \ ControlGetPos ControlGetText ControlMove ControlSend ControlSendRaw
112 \ ControlSetText Menu PostMessage SendMessage SetControlDelay
113 \ WinMenuSelectItem GroupActivate GroupAdd GroupClose GroupDeactivate
114 \ DetectHiddenText DetectHiddenWindows SetTitleMatchMode SetWinDelay
115 \ StatusBarGetText StatusBarWait WinActivate WinActivateBottom WinClose
116 \ WinGet WinGetActiveStats WinGetActiveTitle WinGetClass WinGetPos
117 \ WinGetText WinGetTitle WinHide WinKill WinMaximize WinMinimize
118 \ WinMinimizeAll WinMinimizeAllUndo WinMove WinRestore WinSet
119 \ WinSetTitle WinShow WinWait WinWaitActive WinWaitNotActive WinWaitClose
Bram Moolenaar690afe12017-01-28 18:34:47 +0100120 \ SetCapsLockState SetNumLockState SetScrollLockState
Bram Moolenaarb6799ac2007-05-10 16:44:05 +0000121
122syn keyword autohotkeyFunction
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +0200123 \ InStr RegExMatch RegExReplace StrLen SubStr Asc Chr Func
Bram Moolenaarb6799ac2007-05-10 16:44:05 +0000124 \ DllCall VarSetCapacity WinActive WinExist IsLabel OnMessage
125 \ Abs Ceil Exp Floor Log Ln Mod Round Sqrt Sin Cos Tan ASin ACos ATan
Bram Moolenaar690afe12017-01-28 18:34:47 +0100126 \ FileExist GetKeyState NumGet NumPut StrGet StrPut RegisterCallback
127 \ IsFunc Trim LTrim RTrim IsObject Object Array FileOpen
128 \ ComObjActive ComObjArray ComObjConnect ComObjCreate ComObjGet
129 \ ComObjError ComObjFlags ComObjQuery ComObjType ComObjValue ComObject
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +0200130 \ Format Exception
Bram Moolenaarb6799ac2007-05-10 16:44:05 +0000131
132syn keyword autohotkeyStatement
133 \ Break Continue Exit ExitApp Gosub Goto OnExit Pause Return
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +0200134 \ Suspend Reload new class extends
Bram Moolenaarb6799ac2007-05-10 16:44:05 +0000135
136syn keyword autohotkeyRepeat
137 \ Loop
138
139syn keyword autohotkeyConditional
140 \ IfExist IfNotExist If IfEqual IfLess IfGreater Else
Bram Moolenaar690afe12017-01-28 18:34:47 +0100141 \ IfWinExist IfWinNotExist IfWinActive IfWinNotActive
142 \ IfNotEqual IfLessOrEqual IfGreaterOrEqual
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +0200143 \ while until for in try catch finally
Bram Moolenaarb6799ac2007-05-10 16:44:05 +0000144
145syn match autohotkeyPreProcStart
146 \ nextgroup=
147 \ autohotkeyInclude,
148 \ autohotkeyPreProc
149 \ skipwhite
150 \ display
151 \ '^\s*\zs#'
152
153syn keyword autohotkeyInclude
154 \ contained
155 \ Include
156 \ IncludeAgain
157
158syn keyword autohotkeyPreProc
159 \ contained
160 \ HotkeyInterval HotKeyModifierTimeout
161 \ Hotstring
162 \ IfWinActive IfWinNotActive IfWinExist IfWinNotExist
Bram Moolenaar690afe12017-01-28 18:34:47 +0100163 \ If IfTimeout
Bram Moolenaarb6799ac2007-05-10 16:44:05 +0000164 \ MaxHotkeysPerInterval MaxThreads MaxThreadsBuffer MaxThreadsPerHotkey
165 \ UseHook InstallKeybdHook InstallMouseHook
166 \ KeyHistory
167 \ NoTrayIcon SingleInstance
168 \ WinActivateForce
169 \ AllowSameLineComments
170 \ ClipboardTimeout
171 \ CommentFlag
172 \ ErrorStdOut
173 \ EscapeChar
174 \ MaxMem
175 \ NoEnv
176 \ Persistent
Bram Moolenaar690afe12017-01-28 18:34:47 +0100177 \ LTrim
178 \ InputLevel
179 \ MenuMaskKey
180 \ Warn
Bram Moolenaarb6799ac2007-05-10 16:44:05 +0000181
182syn keyword autohotkeyMatchClass
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +0200183 \ ahk_group ahk_class ahk_id ahk_pid ahk_exe
Bram Moolenaarb6799ac2007-05-10 16:44:05 +0000184
185syn match autohotkeyNumbers
186 \ display
187 \ transparent
188 \ contains=
189 \ autohotkeyInteger,
190 \ autohotkeyFloat
191 \ '\<\d\|\.\d'
192
193syn match autohotkeyInteger
194 \ contained
195 \ display
196 \ '\d\+\>'
197
198syn match autohotkeyInteger
199 \ contained
200 \ display
201 \ '0x\x\+\>'
202
203syn match autohotkeyFloat
204 \ contained
205 \ display
206 \ '\d\+\.\d*\|\.\d\+\>'
207
208syn keyword autohotkeyType
209 \ local
210 \ global
Bram Moolenaar690afe12017-01-28 18:34:47 +0100211 \ static
212 \ byref
Bram Moolenaarb6799ac2007-05-10 16:44:05 +0000213
Bram Moolenaarf2330482008-06-24 20:19:36 +0000214syn keyword autohotkeyBoolean
215 \ true
216 \ false
217
Bram Moolenaar690afe12017-01-28 18:34:47 +0100218syn match autohotkeyHotkey
219 \ contains=autohotkeyKey,
220 \ autohotkeyHotkeyDelimiter
221 \ display
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +0200222 \ '^\s*\S*\%( Up\)\?::'
Bram Moolenaar690afe12017-01-28 18:34:47 +0100223
224syn match autohotkeyKey
225 \ contained
226 \ display
227 \ '^.\{-}'
228
229syn match autohotkeyDelimiter
230 \ contained
231 \ display
232 \ '::'
233
234" allowable hotstring options:
235" https://autohotkey.com/docs/Hotstrings.htm
236syn match autohotkeyHotstringDefinition
237 \ contains=autohotkeyHotstring,
238 \ autohotkeyHotstringDelimiter
239 \ display
240 \ '^\s*:\%([*?]\|[BORZ]0\?\|C[01]\?\|K\d\+\|P\d\+\|S[IPE]\)*:.\{-}::'
241
242syn match autohotkeyHotstring
243 \ contained
244 \ display
245 \ '.\{-}'
246
247syn match autohotkeyHotstringDelimiter
248 \ contained
249 \ display
250 \ '::'
251
252syn match autohotkeyHotstringDelimiter
253 \ contains=autohotkeyHotstringOptions
254 \ contained
255 \ display
256 \ ':\%([*?]\|[BORZ]0\?\|C[01]\?\|K\d\+\|P\d\+\|S[IPE]\)*:'
257
258syn match autohotkeyHotstringOptions
259 \ contained
260 \ display
261 \ '\%([*?]\|[BORZ]0\?\|C[01]\?\|K\d\+\|P\d\+\|S[IPE]\)*'
262
263syn cluster autohotkeyCommentGroup
264 \ contains=
265 \ autohotkeyTodo,
266 \ @Spell
267
268syn match autohotkeyComment
269 \ display
270 \ contains=@autohotkeyCommentGroup
271 \ '\%(^;\|\s\+;\).*$'
272
273syn region autohotkeyComment
274 \ contains=@autohotkeyCommentGroup
275 \ matchgroup=autohotkeyCommentStart
276 \ start='^\s*/\*'
277 \ end='^\s*\*/'
278
Bram Moolenaare37d50a2008-08-06 17:06:04 +0000279" TODO: Shouldn't we look for g:, b:, variables before defaulting to
280" something?
281if exists("g:autohotkey_syntax_sync_minlines")
282 let b:autohotkey_syntax_sync_minlines = g:autohotkey_syntax_sync_minlines
283else
284 let b:autohotkey_syntax_sync_minlines = 50
285endif
286exec "syn sync ccomment autohotkeyComment minlines=" . b:autohotkey_syntax_sync_minlines
287
Bram Moolenaarb6799ac2007-05-10 16:44:05 +0000288hi def link autohotkeyTodo Todo
289hi def link autohotkeyComment Comment
290hi def link autohotkeyCommentStart autohotkeyComment
291hi def link autohotkeyEscape Special
292hi def link autohotkeyHotkey Type
293hi def link autohotkeyKey Type
294hi def link autohotkeyDelimiter Delimiter
295hi def link autohotkeyHotstringDefinition Type
296hi def link autohotkeyHotstring Type
297hi def link autohotkeyHotstringDelimiter autohotkeyDelimiter
298hi def link autohotkeyHotstringOptions Special
299hi def link autohotkeyString String
300hi def link autohotkeyStringDelimiter autohotkeyString
301hi def link autohotkeyVariable Identifier
302hi def link autohotkeyVariableDelimiter autohotkeyVariable
303hi def link autohotkeyBuiltinVariable Macro
304hi def link autohotkeyCommand Keyword
305hi def link autohotkeyFunction Function
306hi def link autohotkeyStatement autohotkeyCommand
307hi def link autohotkeyRepeat Repeat
308hi def link autohotkeyConditional Conditional
309hi def link autohotkeyPreProcStart PreProc
310hi def link autohotkeyInclude Include
311hi def link autohotkeyPreProc PreProc
312hi def link autohotkeyMatchClass Typedef
313hi def link autohotkeyNumber Number
314hi def link autohotkeyInteger autohotkeyNumber
315hi def link autohotkeyFloat autohotkeyNumber
316hi def link autohotkeyType Type
Bram Moolenaarf2330482008-06-24 20:19:36 +0000317hi def link autohotkeyBoolean Boolean
Bram Moolenaarb6799ac2007-05-10 16:44:05 +0000318
319let b:current_syntax = "autohotkey"
320
321let &cpo = s:cpo_save
322unlet s:cpo_save