vim

Fork of vim, an acceptable text editor
git clone git://git.laack.co/vim.git
Log | Files | Refs | README | LICENSE

autohotkey.vim (12140B)


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