1" Vim syntax file 2" Language: AutoHotkey script file 3" Maintainer: Michael Wong 4" https://github.com/mmikeww/autohotkey.vim 5" Latest Revision: 2017-04-03 6" Previous Maintainers: SungHyun Nam <goweol@gmail.com> 7" Nikolai Weibull <now@bitwi.se> 8 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 22" only these chars are valid as escape sequences: ,%`;nrbtvaf 23" https://autohotkey.com/docs/commands/_EscapeChar.htm 24syn match autohotkeyEscape 25 \ display 26 \ '`[,%`;nrbtvaf]' 27 28syn region autohotkeyString 29 \ display 30 \ oneline 31 \ matchgroup=autohotkeyStringDelimiter 32 \ start=+"+ 33 \ end=+"+ 34 \ contains=autohotkeyEscape 35 36syn match autohotkeyVariable 37 \ display 38 \ oneline 39 \ contains=autohotkeyBuiltinVariable 40 \ keepend 41 \ '%\S\{-}%' 42 43syn keyword autohotkeyBuiltinVariable 44 \ A_Space A_Tab 45 \ 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 49 \ A_Sec A_MSec A_Now A_NowUTC A_TickCount 50 \ 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 57 \ A_IconNumber 58 \ A_TimeIdle A_TimeIdlePhysical A_DefaultGui A_DefaultListView A_DefaultTreeView 59 \ 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 62 \ A_PriorKey A_TimeSinceThisHotkey A_TimeSincePriorHotkey A_EndChar 63 \ ComSpec A_Temp A_OSType A_OSVersion A_Language A_ComputerName A_UserName 64 \ A_Is64BitOS A_PtrSize 65 \ 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 68 \ A_ScreenWidth A_ScreenHeight A_ScreenDPI A_IPAddress1 A_IPAddress2 A_IPAddress3 69 \ 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 72 \ 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 76 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 85 \ FileCreateDir FileCreateShortcut FileDelete FileGetAttrib FileEncoding 86 \ 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 108 \ StringSplit StringTrimLeft StringTrimRight StringLen 109 \ StrSplit StrReplace Throw 110 \ 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 120 \ SetCapsLockState SetNumLockState SetScrollLockState 121 122syn keyword autohotkeyFunction 123 \ InStr RegExMatch RegExReplace StrLen SubStr Asc Chr Func 124 \ DllCall VarSetCapacity WinActive WinExist IsLabel OnMessage 125 \ Abs Ceil Exp Floor Log Ln Mod Round Sqrt Sin Cos Tan ASin ACos ATan 126 \ 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 130 \ Format Exception 131 132syn keyword autohotkeyStatement 133 \ Break Continue Exit ExitApp Gosub Goto OnExit Pause Return 134 \ Suspend Reload new class extends 135 136syn keyword autohotkeyRepeat 137 \ Loop 138 139syn keyword autohotkeyConditional 140 \ IfExist IfNotExist If IfEqual IfLess IfGreater Else 141 \ IfWinExist IfWinNotExist IfWinActive IfWinNotActive 142 \ IfNotEqual IfLessOrEqual IfGreaterOrEqual 143 \ while until for in try catch finally 144 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 163 \ If IfTimeout 164 \ 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 177 \ LTrim 178 \ InputLevel 179 \ MenuMaskKey 180 \ Warn 181 182syn keyword autohotkeyMatchClass 183 \ ahk_group ahk_class ahk_id ahk_pid ahk_exe 184 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 211 \ static 212 \ byref 213 214syn keyword autohotkeyBoolean 215 \ true 216 \ false 217 218syn match autohotkeyHotkey 219 \ contains=autohotkeyKey, 220 \ autohotkeyHotkeyDelimiter 221 \ display 222 \ '^\s*\S*\%( Up\)\?::' 223 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 279" 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 288hi 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 317hi def link autohotkeyBoolean Boolean 318 319let b:current_syntax = "autohotkey" 320 321let &cpo = s:cpo_save 322unlet s:cpo_save 323