autohotkey.vim 12 KB

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