blob: a8883949231cfc0402c7623136dc49aa32a90623 [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 Moolenaar2ecbe532022-07-29 21:36:21 +01005" Latest Revision: 2022-07-25
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=+"+
Bram Moolenaar2ecbe532022-07-29 21:36:21 +010034 \ contains=autohotkeyEscape,autohotkeyMatchClass
Bram Moolenaarb6799ac2007-05-10 16:44:05 +000035
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
Bram Moolenaar2ecbe532022-07-29 21:36:21 +010052 \ A_FileEncoding A_FormatInteger A_FormatFloat A_WinDelay A_ControlDelay
53 \ A_SendMode A_SendLevel A_StoreCapsLockMode A_KeyDelay A_KeyDuration
54 \ A_KeyDelayPlay A_KeyDurationPlay A_MouseDelayPlay
Bram Moolenaar690afe12017-01-28 18:34:47 +010055 \ 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 Moolenaar2ecbe532022-07-29 21:36:21 +010076 \ A_TimeIdleKeyboard A_TimeIdleMouse A_ListLines A_ComSpec A_LoopFilePath A_Args
Bram Moolenaarb6799ac2007-05-10 16:44:05 +000077
78syn match autohotkeyBuiltinVariable
79 \ contained
80 \ display
81 \ '%\d\+%'
82
83syn keyword autohotkeyCommand
84 \ ClipWait EnvGet EnvSet EnvUpdate
85 \ Drive DriveGet DriveSpaceFree FileAppend FileCopy FileCopyDir
Bram Moolenaar690afe12017-01-28 18:34:47 +010086 \ FileCreateDir FileCreateShortcut FileDelete FileGetAttrib FileEncoding
Bram Moolenaarb6799ac2007-05-10 16:44:05 +000087 \ FileGetShortcut FileGetSize FileGetTime FileGetVersion FileInstall
88 \ FileMove FileMoveDir FileReadLine FileRead FileRecycle FileRecycleEmpty
89 \ FileRemoveDir FileSelectFolder FileSelectFile FileSetAttrib FileSetTime
90 \ IniDelete IniRead IniWrite SetWorkingDir
91 \ SplitPath
92 \ Gui GuiControl GuiControlGet IfMsgBox InputBox MsgBox Progress
93 \ SplashImage SplashTextOn SplashTextOff ToolTip TrayTip
94 \ Hotkey ListHotkeys BlockInput ControlSend ControlSendRaw GetKeyState
95 \ KeyHistory KeyWait Input Send SendRaw SendInput SendPlay SendEvent
96 \ SendMode SetKeyDelay SetNumScrollCapsLockState SetStoreCapslockMode
97 \ EnvAdd EnvDiv EnvMult EnvSub Random SetFormat Transform
98 \ AutoTrim BlockInput CoordMode Critical Edit ImageSearch
99 \ ListLines ListVars Menu OutputDebug PixelGetColor PixelSearch
100 \ SetBatchLines SetEnv SetTimer SysGet Thread Transform URLDownloadToFile
101 \ Click ControlClick MouseClick MouseClickDrag MouseGetPos MouseMove
102 \ SetDefaultMouseSpeed SetMouseDelay
103 \ Process Run RunWait RunAs Shutdown Sleep
104 \ RegDelete RegRead RegWrite
105 \ SoundBeep SoundGet SoundGetWaveVolume SoundPlay SoundSet
106 \ SoundSetWaveVolume
107 \ FormatTime IfInString IfNotInString Sort StringCaseSense StringGetPos
108 \ StringLeft StringRight StringLower StringUpper StringMid StringReplace
Bram Moolenaar690afe12017-01-28 18:34:47 +0100109 \ StringSplit StringTrimLeft StringTrimRight StringLen
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +0200110 \ StrSplit StrReplace Throw
Bram Moolenaarb6799ac2007-05-10 16:44:05 +0000111 \ Control ControlClick ControlFocus ControlGet ControlGetFocus
112 \ ControlGetPos ControlGetText ControlMove ControlSend ControlSendRaw
113 \ ControlSetText Menu PostMessage SendMessage SetControlDelay
114 \ WinMenuSelectItem GroupActivate GroupAdd GroupClose GroupDeactivate
115 \ DetectHiddenText DetectHiddenWindows SetTitleMatchMode SetWinDelay
116 \ StatusBarGetText StatusBarWait WinActivate WinActivateBottom WinClose
117 \ WinGet WinGetActiveStats WinGetActiveTitle WinGetClass WinGetPos
118 \ WinGetText WinGetTitle WinHide WinKill WinMaximize WinMinimize
119 \ WinMinimizeAll WinMinimizeAllUndo WinMove WinRestore WinSet
120 \ WinSetTitle WinShow WinWait WinWaitActive WinWaitNotActive WinWaitClose
Bram Moolenaar690afe12017-01-28 18:34:47 +0100121 \ SetCapsLockState SetNumLockState SetScrollLockState
Bram Moolenaar2ecbe532022-07-29 21:36:21 +0100122 \ Hotstring LoadPicture MenuGetHandle MenuGetName OnError OnClipboardChange
Bram Moolenaarb6799ac2007-05-10 16:44:05 +0000123
124syn keyword autohotkeyFunction
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +0200125 \ InStr RegExMatch RegExReplace StrLen SubStr Asc Chr Func
Bram Moolenaarb6799ac2007-05-10 16:44:05 +0000126 \ DllCall VarSetCapacity WinActive WinExist IsLabel OnMessage
127 \ Abs Ceil Exp Floor Log Ln Mod Round Sqrt Sin Cos Tan ASin ACos ATan
Bram Moolenaar690afe12017-01-28 18:34:47 +0100128 \ FileExist GetKeyState NumGet NumPut StrGet StrPut RegisterCallback
129 \ IsFunc Trim LTrim RTrim IsObject Object Array FileOpen
130 \ ComObjActive ComObjArray ComObjConnect ComObjCreate ComObjGet
131 \ ComObjError ComObjFlags ComObjQuery ComObjType ComObjValue ComObject
Bram Moolenaar2ecbe532022-07-29 21:36:21 +0100132 \ Format Exception Ord InputHook
Bram Moolenaarb6799ac2007-05-10 16:44:05 +0000133
134syn keyword autohotkeyStatement
135 \ Break Continue Exit ExitApp Gosub Goto OnExit Pause Return
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +0200136 \ Suspend Reload new class extends
Bram Moolenaarb6799ac2007-05-10 16:44:05 +0000137
138syn keyword autohotkeyRepeat
139 \ Loop
140
141syn keyword autohotkeyConditional
142 \ IfExist IfNotExist If IfEqual IfLess IfGreater Else
Bram Moolenaar690afe12017-01-28 18:34:47 +0100143 \ IfWinExist IfWinNotExist IfWinActive IfWinNotActive
144 \ IfNotEqual IfLessOrEqual IfGreaterOrEqual
Bram Moolenaar2ecbe532022-07-29 21:36:21 +0100145 \ while until for in try catch finally not
146 \ switch case default
Bram Moolenaarb6799ac2007-05-10 16:44:05 +0000147
148syn match autohotkeyPreProcStart
149 \ nextgroup=
150 \ autohotkeyInclude,
151 \ autohotkeyPreProc
152 \ skipwhite
153 \ display
154 \ '^\s*\zs#'
155
156syn keyword autohotkeyInclude
157 \ contained
158 \ Include
159 \ IncludeAgain
160
161syn keyword autohotkeyPreProc
162 \ contained
163 \ HotkeyInterval HotKeyModifierTimeout
164 \ Hotstring
165 \ IfWinActive IfWinNotActive IfWinExist IfWinNotExist
Bram Moolenaar690afe12017-01-28 18:34:47 +0100166 \ If IfTimeout
Bram Moolenaarb6799ac2007-05-10 16:44:05 +0000167 \ MaxHotkeysPerInterval MaxThreads MaxThreadsBuffer MaxThreadsPerHotkey
168 \ UseHook InstallKeybdHook InstallMouseHook
169 \ KeyHistory
170 \ NoTrayIcon SingleInstance
171 \ WinActivateForce
172 \ AllowSameLineComments
173 \ ClipboardTimeout
174 \ CommentFlag
175 \ ErrorStdOut
176 \ EscapeChar
177 \ MaxMem
178 \ NoEnv
179 \ Persistent
Bram Moolenaar690afe12017-01-28 18:34:47 +0100180 \ LTrim
181 \ InputLevel
182 \ MenuMaskKey
183 \ Warn
Bram Moolenaarb6799ac2007-05-10 16:44:05 +0000184
185syn keyword autohotkeyMatchClass
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +0200186 \ ahk_group ahk_class ahk_id ahk_pid ahk_exe
Bram Moolenaarb6799ac2007-05-10 16:44:05 +0000187
188syn match autohotkeyNumbers
189 \ display
190 \ transparent
191 \ contains=
192 \ autohotkeyInteger,
193 \ autohotkeyFloat
194 \ '\<\d\|\.\d'
195
196syn match autohotkeyInteger
197 \ contained
198 \ display
199 \ '\d\+\>'
200
201syn match autohotkeyInteger
202 \ contained
203 \ display
204 \ '0x\x\+\>'
205
206syn match autohotkeyFloat
207 \ contained
208 \ display
209 \ '\d\+\.\d*\|\.\d\+\>'
210
211syn keyword autohotkeyType
212 \ local
213 \ global
Bram Moolenaar690afe12017-01-28 18:34:47 +0100214 \ static
215 \ byref
Bram Moolenaarb6799ac2007-05-10 16:44:05 +0000216
Bram Moolenaarf2330482008-06-24 20:19:36 +0000217syn keyword autohotkeyBoolean
218 \ true
219 \ false
220
Bram Moolenaar690afe12017-01-28 18:34:47 +0100221syn match autohotkeyHotkey
222 \ contains=autohotkeyKey,
223 \ autohotkeyHotkeyDelimiter
224 \ display
Bram Moolenaarcd5c8f82017-04-09 20:11:58 +0200225 \ '^\s*\S*\%( Up\)\?::'
Bram Moolenaar690afe12017-01-28 18:34:47 +0100226
227syn match autohotkeyKey
228 \ contained
229 \ display
230 \ '^.\{-}'
231
232syn match autohotkeyDelimiter
233 \ contained
234 \ display
235 \ '::'
236
237" allowable hotstring options:
238" https://autohotkey.com/docs/Hotstrings.htm
239syn match autohotkeyHotstringDefinition
240 \ contains=autohotkeyHotstring,
241 \ autohotkeyHotstringDelimiter
242 \ display
243 \ '^\s*:\%([*?]\|[BORZ]0\?\|C[01]\?\|K\d\+\|P\d\+\|S[IPE]\)*:.\{-}::'
244
245syn match autohotkeyHotstring
246 \ contained
247 \ display
248 \ '.\{-}'
249
250syn match autohotkeyHotstringDelimiter
251 \ contained
252 \ display
253 \ '::'
254
255syn match autohotkeyHotstringDelimiter
256 \ contains=autohotkeyHotstringOptions
257 \ contained
258 \ display
259 \ ':\%([*?]\|[BORZ]0\?\|C[01]\?\|K\d\+\|P\d\+\|S[IPE]\)*:'
260
261syn match autohotkeyHotstringOptions
262 \ contained
263 \ display
264 \ '\%([*?]\|[BORZ]0\?\|C[01]\?\|K\d\+\|P\d\+\|S[IPE]\)*'
265
266syn cluster autohotkeyCommentGroup
267 \ contains=
268 \ autohotkeyTodo,
269 \ @Spell
270
271syn match autohotkeyComment
272 \ display
273 \ contains=@autohotkeyCommentGroup
274 \ '\%(^;\|\s\+;\).*$'
275
276syn region autohotkeyComment
277 \ contains=@autohotkeyCommentGroup
278 \ matchgroup=autohotkeyCommentStart
279 \ start='^\s*/\*'
280 \ end='^\s*\*/'
281
Bram Moolenaare37d50a2008-08-06 17:06:04 +0000282" TODO: Shouldn't we look for g:, b:, variables before defaulting to
283" something?
284if exists("g:autohotkey_syntax_sync_minlines")
285 let b:autohotkey_syntax_sync_minlines = g:autohotkey_syntax_sync_minlines
286else
287 let b:autohotkey_syntax_sync_minlines = 50
288endif
289exec "syn sync ccomment autohotkeyComment minlines=" . b:autohotkey_syntax_sync_minlines
290
Bram Moolenaarb6799ac2007-05-10 16:44:05 +0000291hi def link autohotkeyTodo Todo
292hi def link autohotkeyComment Comment
293hi def link autohotkeyCommentStart autohotkeyComment
294hi def link autohotkeyEscape Special
295hi def link autohotkeyHotkey Type
296hi def link autohotkeyKey Type
297hi def link autohotkeyDelimiter Delimiter
298hi def link autohotkeyHotstringDefinition Type
299hi def link autohotkeyHotstring Type
300hi def link autohotkeyHotstringDelimiter autohotkeyDelimiter
301hi def link autohotkeyHotstringOptions Special
302hi def link autohotkeyString String
303hi def link autohotkeyStringDelimiter autohotkeyString
304hi def link autohotkeyVariable Identifier
305hi def link autohotkeyVariableDelimiter autohotkeyVariable
306hi def link autohotkeyBuiltinVariable Macro
307hi def link autohotkeyCommand Keyword
308hi def link autohotkeyFunction Function
309hi def link autohotkeyStatement autohotkeyCommand
310hi def link autohotkeyRepeat Repeat
311hi def link autohotkeyConditional Conditional
312hi def link autohotkeyPreProcStart PreProc
313hi def link autohotkeyInclude Include
314hi def link autohotkeyPreProc PreProc
315hi def link autohotkeyMatchClass Typedef
316hi def link autohotkeyNumber Number
317hi def link autohotkeyInteger autohotkeyNumber
318hi def link autohotkeyFloat autohotkeyNumber
319hi def link autohotkeyType Type
Bram Moolenaarf2330482008-06-24 20:19:36 +0000320hi def link autohotkeyBoolean Boolean
Bram Moolenaarb6799ac2007-05-10 16:44:05 +0000321
322let b:current_syntax = "autohotkey"
323
324let &cpo = s:cpo_save
325unlet s:cpo_save