autohotkey.vim 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  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. 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
  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_KeyDelay A_WinDelay A_ControlDelay
  45. \ A_SendMode A_SendLevel A_StoreCapsLockMode A_KeyDelay A_KeyDelayDuration
  46. \ A_KeyDelayPlay A_KeyDelayPlayDuration 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. syn match autohotkeyBuiltinVariable
  69. \ contained
  70. \ display
  71. \ '%\d\+%'
  72. syn keyword autohotkeyCommand
  73. \ ClipWait EnvGet EnvSet EnvUpdate
  74. \ Drive DriveGet DriveSpaceFree FileAppend FileCopy FileCopyDir
  75. \ FileCreateDir FileCreateShortcut FileDelete FileGetAttrib FileEncoding
  76. \ FileGetShortcut FileGetSize FileGetTime FileGetVersion FileInstall
  77. \ FileMove FileMoveDir FileReadLine FileRead FileRecycle FileRecycleEmpty
  78. \ FileRemoveDir FileSelectFolder FileSelectFile FileSetAttrib FileSetTime
  79. \ IniDelete IniRead IniWrite SetWorkingDir
  80. \ SplitPath
  81. \ Gui GuiControl GuiControlGet IfMsgBox InputBox MsgBox Progress
  82. \ SplashImage SplashTextOn SplashTextOff ToolTip TrayTip
  83. \ Hotkey ListHotkeys BlockInput ControlSend ControlSendRaw GetKeyState
  84. \ KeyHistory KeyWait Input Send SendRaw SendInput SendPlay SendEvent
  85. \ SendMode SetKeyDelay SetNumScrollCapsLockState SetStoreCapslockMode
  86. \ EnvAdd EnvDiv EnvMult EnvSub Random SetFormat Transform
  87. \ AutoTrim BlockInput CoordMode Critical Edit ImageSearch
  88. \ ListLines ListVars Menu OutputDebug PixelGetColor PixelSearch
  89. \ SetBatchLines SetEnv SetTimer SysGet Thread Transform URLDownloadToFile
  90. \ Click ControlClick MouseClick MouseClickDrag MouseGetPos MouseMove
  91. \ SetDefaultMouseSpeed SetMouseDelay
  92. \ Process Run RunWait RunAs Shutdown Sleep
  93. \ RegDelete RegRead RegWrite
  94. \ SoundBeep SoundGet SoundGetWaveVolume SoundPlay SoundSet
  95. \ SoundSetWaveVolume
  96. \ FormatTime IfInString IfNotInString Sort StringCaseSense StringGetPos
  97. \ StringLeft StringRight StringLower StringUpper StringMid StringReplace
  98. \ StringSplit StringTrimLeft StringTrimRight StringLen
  99. \ StrSplit StrReplace Throw
  100. \ Control ControlClick ControlFocus ControlGet ControlGetFocus
  101. \ ControlGetPos ControlGetText ControlMove ControlSend ControlSendRaw
  102. \ ControlSetText Menu PostMessage SendMessage SetControlDelay
  103. \ WinMenuSelectItem GroupActivate GroupAdd GroupClose GroupDeactivate
  104. \ DetectHiddenText DetectHiddenWindows SetTitleMatchMode SetWinDelay
  105. \ StatusBarGetText StatusBarWait WinActivate WinActivateBottom WinClose
  106. \ WinGet WinGetActiveStats WinGetActiveTitle WinGetClass WinGetPos
  107. \ WinGetText WinGetTitle WinHide WinKill WinMaximize WinMinimize
  108. \ WinMinimizeAll WinMinimizeAllUndo WinMove WinRestore WinSet
  109. \ WinSetTitle WinShow WinWait WinWaitActive WinWaitNotActive WinWaitClose
  110. \ SetCapsLockState SetNumLockState SetScrollLockState
  111. syn keyword autohotkeyFunction
  112. \ InStr RegExMatch RegExReplace StrLen SubStr Asc Chr Func
  113. \ DllCall VarSetCapacity WinActive WinExist IsLabel OnMessage
  114. \ Abs Ceil Exp Floor Log Ln Mod Round Sqrt Sin Cos Tan ASin ACos ATan
  115. \ FileExist GetKeyState NumGet NumPut StrGet StrPut RegisterCallback
  116. \ IsFunc Trim LTrim RTrim IsObject Object Array FileOpen
  117. \ ComObjActive ComObjArray ComObjConnect ComObjCreate ComObjGet
  118. \ ComObjError ComObjFlags ComObjQuery ComObjType ComObjValue ComObject
  119. \ Format Exception
  120. syn keyword autohotkeyStatement
  121. \ Break Continue Exit ExitApp Gosub Goto OnExit Pause Return
  122. \ Suspend Reload new class extends
  123. syn keyword autohotkeyRepeat
  124. \ Loop
  125. syn keyword autohotkeyConditional
  126. \ IfExist IfNotExist If IfEqual IfLess IfGreater Else
  127. \ IfWinExist IfWinNotExist IfWinActive IfWinNotActive
  128. \ IfNotEqual IfLessOrEqual IfGreaterOrEqual
  129. \ while until for in try catch finally
  130. syn match autohotkeyPreProcStart
  131. \ nextgroup=
  132. \ autohotkeyInclude,
  133. \ autohotkeyPreProc
  134. \ skipwhite
  135. \ display
  136. \ '^\s*\zs#'
  137. syn keyword autohotkeyInclude
  138. \ contained
  139. \ Include
  140. \ IncludeAgain
  141. syn keyword autohotkeyPreProc
  142. \ contained
  143. \ HotkeyInterval HotKeyModifierTimeout
  144. \ Hotstring
  145. \ IfWinActive IfWinNotActive IfWinExist IfWinNotExist
  146. \ If IfTimeout
  147. \ MaxHotkeysPerInterval MaxThreads MaxThreadsBuffer MaxThreadsPerHotkey
  148. \ UseHook InstallKeybdHook InstallMouseHook
  149. \ KeyHistory
  150. \ NoTrayIcon SingleInstance
  151. \ WinActivateForce
  152. \ AllowSameLineComments
  153. \ ClipboardTimeout
  154. \ CommentFlag
  155. \ ErrorStdOut
  156. \ EscapeChar
  157. \ MaxMem
  158. \ NoEnv
  159. \ Persistent
  160. \ LTrim
  161. \ InputLevel
  162. \ MenuMaskKey
  163. \ Warn
  164. syn keyword autohotkeyMatchClass
  165. \ ahk_group ahk_class ahk_id ahk_pid ahk_exe
  166. syn match autohotkeyNumbers
  167. \ display
  168. \ transparent
  169. \ contains=
  170. \ autohotkeyInteger,
  171. \ autohotkeyFloat
  172. \ '\<\d\|\.\d'
  173. syn match autohotkeyInteger
  174. \ contained
  175. \ display
  176. \ '\d\+\>'
  177. syn match autohotkeyInteger
  178. \ contained
  179. \ display
  180. \ '0x\x\+\>'
  181. syn match autohotkeyFloat
  182. \ contained
  183. \ display
  184. \ '\d\+\.\d*\|\.\d\+\>'
  185. syn keyword autohotkeyType
  186. \ local
  187. \ global
  188. \ static
  189. \ byref
  190. syn keyword autohotkeyBoolean
  191. \ true
  192. \ false
  193. syn match autohotkeyHotkey
  194. \ contains=autohotkeyKey,
  195. \ autohotkeyHotkeyDelimiter
  196. \ display
  197. \ '^\s*\S*\%( Up\)\?::'
  198. syn match autohotkeyKey
  199. \ contained
  200. \ display
  201. \ '^.\{-}'
  202. syn match autohotkeyDelimiter
  203. \ contained
  204. \ display
  205. \ '::'
  206. " allowable hotstring options:
  207. " https://autohotkey.com/docs/Hotstrings.htm
  208. syn match autohotkeyHotstringDefinition
  209. \ contains=autohotkeyHotstring,
  210. \ autohotkeyHotstringDelimiter
  211. \ display
  212. \ '^\s*:\%([*?]\|[BORZ]0\?\|C[01]\?\|K\d\+\|P\d\+\|S[IPE]\)*:.\{-}::'
  213. syn match autohotkeyHotstring
  214. \ contained
  215. \ display
  216. \ '.\{-}'
  217. syn match autohotkeyHotstringDelimiter
  218. \ contained
  219. \ display
  220. \ '::'
  221. syn match autohotkeyHotstringDelimiter
  222. \ contains=autohotkeyHotstringOptions
  223. \ contained
  224. \ display
  225. \ ':\%([*?]\|[BORZ]0\?\|C[01]\?\|K\d\+\|P\d\+\|S[IPE]\)*:'
  226. syn match autohotkeyHotstringOptions
  227. \ contained
  228. \ display
  229. \ '\%([*?]\|[BORZ]0\?\|C[01]\?\|K\d\+\|P\d\+\|S[IPE]\)*'
  230. syn cluster autohotkeyCommentGroup
  231. \ contains=
  232. \ autohotkeyTodo,
  233. \ @Spell
  234. syn match autohotkeyComment
  235. \ display
  236. \ contains=@autohotkeyCommentGroup
  237. \ '\%(^;\|\s\+;\).*$'
  238. syn region autohotkeyComment
  239. \ contains=@autohotkeyCommentGroup
  240. \ matchgroup=autohotkeyCommentStart
  241. \ start='^\s*/\*'
  242. \ end='^\s*\*/'
  243. " TODO: Shouldn't we look for g:, b:, variables before defaulting to
  244. " something?
  245. if exists("g:autohotkey_syntax_sync_minlines")
  246. let b:autohotkey_syntax_sync_minlines = g:autohotkey_syntax_sync_minlines
  247. else
  248. let b:autohotkey_syntax_sync_minlines = 50
  249. endif
  250. exec "syn sync ccomment autohotkeyComment minlines=" . b:autohotkey_syntax_sync_minlines
  251. hi def link autohotkeyTodo Todo
  252. hi def link autohotkeyComment Comment
  253. hi def link autohotkeyCommentStart autohotkeyComment
  254. hi def link autohotkeyEscape Special
  255. hi def link autohotkeyHotkey Type
  256. hi def link autohotkeyKey Type
  257. hi def link autohotkeyDelimiter Delimiter
  258. hi def link autohotkeyHotstringDefinition Type
  259. hi def link autohotkeyHotstring Type
  260. hi def link autohotkeyHotstringDelimiter autohotkeyDelimiter
  261. hi def link autohotkeyHotstringOptions Special
  262. hi def link autohotkeyString String
  263. hi def link autohotkeyStringDelimiter autohotkeyString
  264. hi def link autohotkeyVariable Identifier
  265. hi def link autohotkeyVariableDelimiter autohotkeyVariable
  266. hi def link autohotkeyBuiltinVariable Macro
  267. hi def link autohotkeyCommand Keyword
  268. hi def link autohotkeyFunction Function
  269. hi def link autohotkeyStatement autohotkeyCommand
  270. hi def link autohotkeyRepeat Repeat
  271. hi def link autohotkeyConditional Conditional
  272. hi def link autohotkeyPreProcStart PreProc
  273. hi def link autohotkeyInclude Include
  274. hi def link autohotkeyPreProc PreProc
  275. hi def link autohotkeyMatchClass Typedef
  276. hi def link autohotkeyNumber Number
  277. hi def link autohotkeyInteger autohotkeyNumber
  278. hi def link autohotkeyFloat autohotkeyNumber
  279. hi def link autohotkeyType Type
  280. hi def link autohotkeyBoolean Boolean
  281. let b:current_syntax = "autohotkey"
  282. let &cpo = s:cpo_save
  283. unlet s:cpo_save