blob: 3b826af6f52f87ee5d1849780ab7b4d2c56b1909 [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
5" Latest Revision: 2017-01-23
6" 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 Moolenaarb6799ac2007-05-10 16:44:05 +0000109 \ Control ControlClick ControlFocus ControlGet ControlGetFocus
110 \ ControlGetPos ControlGetText ControlMove ControlSend ControlSendRaw
111 \ ControlSetText Menu PostMessage SendMessage SetControlDelay
112 \ WinMenuSelectItem GroupActivate GroupAdd GroupClose GroupDeactivate
113 \ DetectHiddenText DetectHiddenWindows SetTitleMatchMode SetWinDelay
114 \ StatusBarGetText StatusBarWait WinActivate WinActivateBottom WinClose
115 \ WinGet WinGetActiveStats WinGetActiveTitle WinGetClass WinGetPos
116 \ WinGetText WinGetTitle WinHide WinKill WinMaximize WinMinimize
117 \ WinMinimizeAll WinMinimizeAllUndo WinMove WinRestore WinSet
118 \ WinSetTitle WinShow WinWait WinWaitActive WinWaitNotActive WinWaitClose
Bram Moolenaar690afe12017-01-28 18:34:47 +0100119 \ SetCapsLockState SetNumLockState SetScrollLockState
Bram Moolenaarb6799ac2007-05-10 16:44:05 +0000120
121syn keyword autohotkeyFunction
122 \ InStr RegExMatch RegExReplace StrLen SubStr Asc Chr
123 \ DllCall VarSetCapacity WinActive WinExist IsLabel OnMessage
124 \ Abs Ceil Exp Floor Log Ln Mod Round Sqrt Sin Cos Tan ASin ACos ATan
Bram Moolenaar690afe12017-01-28 18:34:47 +0100125 \ FileExist GetKeyState NumGet NumPut StrGet StrPut RegisterCallback
126 \ IsFunc Trim LTrim RTrim IsObject Object Array FileOpen
127 \ ComObjActive ComObjArray ComObjConnect ComObjCreate ComObjGet
128 \ ComObjError ComObjFlags ComObjQuery ComObjType ComObjValue ComObject
Bram Moolenaarb6799ac2007-05-10 16:44:05 +0000129
130syn keyword autohotkeyStatement
131 \ Break Continue Exit ExitApp Gosub Goto OnExit Pause Return
132 \ Suspend Reload
133
134syn keyword autohotkeyRepeat
135 \ Loop
136
137syn keyword autohotkeyConditional
138 \ IfExist IfNotExist If IfEqual IfLess IfGreater Else
Bram Moolenaar690afe12017-01-28 18:34:47 +0100139 \ IfWinExist IfWinNotExist IfWinActive IfWinNotActive
140 \ IfNotEqual IfLessOrEqual IfGreaterOrEqual
141 \ while until for in
Bram Moolenaarb6799ac2007-05-10 16:44:05 +0000142
143syn match autohotkeyPreProcStart
144 \ nextgroup=
145 \ autohotkeyInclude,
146 \ autohotkeyPreProc
147 \ skipwhite
148 \ display
149 \ '^\s*\zs#'
150
151syn keyword autohotkeyInclude
152 \ contained
153 \ Include
154 \ IncludeAgain
155
156syn keyword autohotkeyPreProc
157 \ contained
158 \ HotkeyInterval HotKeyModifierTimeout
159 \ Hotstring
160 \ IfWinActive IfWinNotActive IfWinExist IfWinNotExist
Bram Moolenaar690afe12017-01-28 18:34:47 +0100161 \ If IfTimeout
Bram Moolenaarb6799ac2007-05-10 16:44:05 +0000162 \ MaxHotkeysPerInterval MaxThreads MaxThreadsBuffer MaxThreadsPerHotkey
163 \ UseHook InstallKeybdHook InstallMouseHook
164 \ KeyHistory
165 \ NoTrayIcon SingleInstance
166 \ WinActivateForce
167 \ AllowSameLineComments
168 \ ClipboardTimeout
169 \ CommentFlag
170 \ ErrorStdOut
171 \ EscapeChar
172 \ MaxMem
173 \ NoEnv
174 \ Persistent
Bram Moolenaar690afe12017-01-28 18:34:47 +0100175 \ LTrim
176 \ InputLevel
177 \ MenuMaskKey
178 \ Warn
Bram Moolenaarb6799ac2007-05-10 16:44:05 +0000179
180syn keyword autohotkeyMatchClass
181 \ ahk_group ahk_class ahk_id ahk_pid
182
183syn match autohotkeyNumbers
184 \ display
185 \ transparent
186 \ contains=
187 \ autohotkeyInteger,
188 \ autohotkeyFloat
189 \ '\<\d\|\.\d'
190
191syn match autohotkeyInteger
192 \ contained
193 \ display
194 \ '\d\+\>'
195
196syn match autohotkeyInteger
197 \ contained
198 \ display
199 \ '0x\x\+\>'
200
201syn match autohotkeyFloat
202 \ contained
203 \ display
204 \ '\d\+\.\d*\|\.\d\+\>'
205
206syn keyword autohotkeyType
207 \ local
208 \ global
Bram Moolenaar690afe12017-01-28 18:34:47 +0100209 \ static
210 \ byref
Bram Moolenaarb6799ac2007-05-10 16:44:05 +0000211
Bram Moolenaarf2330482008-06-24 20:19:36 +0000212syn keyword autohotkeyBoolean
213 \ true
214 \ false
215
Bram Moolenaar690afe12017-01-28 18:34:47 +0100216syn match autohotkeyHotkey
217 \ contains=autohotkeyKey,
218 \ autohotkeyHotkeyDelimiter
219 \ display
220 \ '^.\{-}::'
221
222syn match autohotkeyKey
223 \ contained
224 \ display
225 \ '^.\{-}'
226
227syn match autohotkeyDelimiter
228 \ contained
229 \ display
230 \ '::'
231
232" allowable hotstring options:
233" https://autohotkey.com/docs/Hotstrings.htm
234syn match autohotkeyHotstringDefinition
235 \ contains=autohotkeyHotstring,
236 \ autohotkeyHotstringDelimiter
237 \ display
238 \ '^\s*:\%([*?]\|[BORZ]0\?\|C[01]\?\|K\d\+\|P\d\+\|S[IPE]\)*:.\{-}::'
239
240syn match autohotkeyHotstring
241 \ contained
242 \ display
243 \ '.\{-}'
244
245syn match autohotkeyHotstringDelimiter
246 \ contained
247 \ display
248 \ '::'
249
250syn match autohotkeyHotstringDelimiter
251 \ contains=autohotkeyHotstringOptions
252 \ contained
253 \ display
254 \ ':\%([*?]\|[BORZ]0\?\|C[01]\?\|K\d\+\|P\d\+\|S[IPE]\)*:'
255
256syn match autohotkeyHotstringOptions
257 \ contained
258 \ display
259 \ '\%([*?]\|[BORZ]0\?\|C[01]\?\|K\d\+\|P\d\+\|S[IPE]\)*'
260
261syn cluster autohotkeyCommentGroup
262 \ contains=
263 \ autohotkeyTodo,
264 \ @Spell
265
266syn match autohotkeyComment
267 \ display
268 \ contains=@autohotkeyCommentGroup
269 \ '\%(^;\|\s\+;\).*$'
270
271syn region autohotkeyComment
272 \ contains=@autohotkeyCommentGroup
273 \ matchgroup=autohotkeyCommentStart
274 \ start='^\s*/\*'
275 \ end='^\s*\*/'
276
Bram Moolenaare37d50a2008-08-06 17:06:04 +0000277" TODO: Shouldn't we look for g:, b:, variables before defaulting to
278" something?
279if exists("g:autohotkey_syntax_sync_minlines")
280 let b:autohotkey_syntax_sync_minlines = g:autohotkey_syntax_sync_minlines
281else
282 let b:autohotkey_syntax_sync_minlines = 50
283endif
284exec "syn sync ccomment autohotkeyComment minlines=" . b:autohotkey_syntax_sync_minlines
285
Bram Moolenaarb6799ac2007-05-10 16:44:05 +0000286hi def link autohotkeyTodo Todo
287hi def link autohotkeyComment Comment
288hi def link autohotkeyCommentStart autohotkeyComment
289hi def link autohotkeyEscape Special
290hi def link autohotkeyHotkey Type
291hi def link autohotkeyKey Type
292hi def link autohotkeyDelimiter Delimiter
293hi def link autohotkeyHotstringDefinition Type
294hi def link autohotkeyHotstring Type
295hi def link autohotkeyHotstringDelimiter autohotkeyDelimiter
296hi def link autohotkeyHotstringOptions Special
297hi def link autohotkeyString String
298hi def link autohotkeyStringDelimiter autohotkeyString
299hi def link autohotkeyVariable Identifier
300hi def link autohotkeyVariableDelimiter autohotkeyVariable
301hi def link autohotkeyBuiltinVariable Macro
302hi def link autohotkeyCommand Keyword
303hi def link autohotkeyFunction Function
304hi def link autohotkeyStatement autohotkeyCommand
305hi def link autohotkeyRepeat Repeat
306hi def link autohotkeyConditional Conditional
307hi def link autohotkeyPreProcStart PreProc
308hi def link autohotkeyInclude Include
309hi def link autohotkeyPreProc PreProc
310hi def link autohotkeyMatchClass Typedef
311hi def link autohotkeyNumber Number
312hi def link autohotkeyInteger autohotkeyNumber
313hi def link autohotkeyFloat autohotkeyNumber
314hi def link autohotkeyType Type
Bram Moolenaarf2330482008-06-24 20:19:36 +0000315hi def link autohotkeyBoolean Boolean
Bram Moolenaarb6799ac2007-05-10 16:44:05 +0000316
317let b:current_syntax = "autohotkey"
318
319let &cpo = s:cpo_save
320unlet s:cpo_save