codekingpro/portable-devtools
114k
1" Vim syntax file2" Language: skhd configuration file3" Maintainer: Kiyoon Kim <https://github.com/kiyoon>4" Last Change: 2025 Jan 225 6if exists("b:current_syntax")7 finish8endif9 10" Comments: whole line from '#'11syn match skhdComment /^\s*#.*/12 13" Modifiers (shift, ctrl, alt, cmd, fn)14syn keyword skhdModifier15 \ alt lalt ralt16 \ shift lshift rshift17 \ cmd lcmd rcmd18 \ ctrl lctrl rctrl19 \ fn hyper meh20 \ option super21" highlight the '+' and '-' and ':' separators22syn match skhdOperator /->/23syn match skhdOperator /[+:\-;<>,\[\]@~]/24 25" Hex keycode form: 0x3C etc26syn match skhdKeycode /\v0x[0-9A-Fa-f]+/27 28" Keys (a–z, digits, function‐keys, arrows…)29syn keyword skhdKey30 \ return tab space backspace escape delete31 \ home end pageup pagedown insert32 \ left right up down33 \ sound_up sound_down mute play previous next rewind fast34 \ brightness_up brightness_down illumination_up illumination_down35syn match skhdKey /\vf([1-9]|1[0-9]|20)\>/36syn match skhdKey /\v\<[A-Za-z0-9]\>/37 38" The yabai command and its subcommands39syn match skhdCommand /\<yabai\>\|\<open\>/40syn match skhdSubCmd /\<window\>\|\<space\>\|\<display\>/41 42" ───────────────────────────────────────────────────────────────────43" Treat anything after a single “:” (not double‑colon) as bash44" ───────────────────────────────────────────────────────────────────45" load Vim’s built‑in shell rules46syntax include @bash syntax/bash.vim47 48" After `:` (not `::`) is a bash command, but not when it is preceded by a `\`49syn region skhdBash50 \ matchgroup=skhdOperator51 \ start=/\v(^|[^:])\zs:\s*/52 \ end=/\v\s*$\ze/53 \ skip=/\v\\\s*$/54 \ keepend55 \ contains=@bash56 57" ────────────────────────────────────────────────────────────────58" Key‑map group definitions and switches59" ────────────────────────────────────────────────────────────────60" In skhd, you can define groups and assign hotkeys to them as follows:61" 1. Group‑definition lines that start with :: <group>62" 2. Switch operator (<)63" 3. Target group names after the ;64 65" Lines like `:: default` or `:: passthrough`66" match the whole thing as a GroupDef, but capture the group name67syn match skhdGroupDef /^::\s*\w\+/68syn match skhdGroupName /::\s*\zs\w\+/69 70" The `<` switch token in lines like71" passthrough < cmd + shift + alt - b ; default72syn match skhdSwitch /<\s*/73 74" The target (or “fall‑through”) group after the semicolon75" ... ; default76syn match skhdTargetGroup /;\s*\zs\w\+/77 78 79" ------------------------------------------------------------80" Application-specific bindings block: <keysym> [ ... ]81" ------------------------------------------------------------82 83" The whole block. This avoids grabbing .blacklist by requiring the line be just '[' at end.84syn region skhdProcMapBlock85 \ matchgroup=skhdProcMapDelim86 \ start=/\v\[\s*$/87 \ end=/^\s*\]\s*$/88 \ keepend89 \ transparent90 \ contains=skhdProcMapApp,skhdProcMapWildcard,skhdProcMapUnbind,skhdOperator,skhdComment,skhdBash,skhdString91 92" App name on the left side: "Google Chrome" :93syn match skhdProcMapApp /^\s*\zs"[^"]*"\ze\s*:\s*/ contained94 95" Wildcard entry: * :96syn match skhdProcMapWildcard /^\s*\zs\*\ze\s*:\s*/ contained97 98" Unbind operator on the right side: "App" ~ or * ~99syn match skhdProcMapUnbind /\v^\s*(\"[^"]*\"|\*)\s*\zs\~\ze\s*$/ contained100 101syn keyword skhdDirective .load .blacklist102syn match skhdLoadLine /^\s*\.load\>\s\+/ contains=skhdDirective103 104syn region skhdBlacklistBlock105 \ start=/^\s*\.blacklist\>\s*\[\s*$/106 \ end=/^\s*\]\s*$/107 \ keepend108 \ contains=skhdDirective,skhdComment,skhdString109 110syn region skhdString start=/"/ skip=/\\"/ end=/"/111 112" ────────────────────────────────────────────────────────────────113" Linking to standard Vim highlight groups114" ────────────────────────────────────────────────────────────────115hi def link skhdComment Comment116hi def link skhdHeadline Title117hi def link skhdModifier Keyword118hi def link skhdOperator Operator119hi def link skhdWildcard Special120hi def link skhdKey Identifier121hi def link skhdKeycode Number122hi def link skhdCommand Function123hi def link skhdSubCmd Statement124hi def link skhdGroupDef Label125hi def link skhdGroupName Identifier126hi def link skhdSwitch Operator127hi def link skhdTargetGroup Type128hi def link skhdString String129 130hi def link skhdProcMapDelim Operator131hi def link skhdProcMapApp Type132hi def link skhdProcMapWildcard Special133hi def link skhdProcMapUnbind Special134 135hi def link skhdDirective PreProc136 137let b:current_syntax = "skhd"138 