robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

zeertzjqMerge pull request #37556 from zeertzjq/vim-9.1.210995b03171df

master
5.3 KiB137 linesraw
1" Vim syntax file
2" Language:	skhd configuration file
3" Maintainer:	Kiyoon Kim <https://github.com/kiyoon>
4" Last Change:	2025 Jan 22
5
6if exists("b:current_syntax")
7  finish
8endif
9
10" Comments: whole line from '#'
11syn match skhdComment /^\s*#.*/
12
13" Modifiers (shift, ctrl, alt, cmd, fn)
14syn keyword skhdModifier
15      \ alt lalt ralt
16      \ shift lshift rshift
17      \ cmd lcmd rcmd
18      \ ctrl lctrl rctrl
19      \ fn hyper meh
20      \ option super
21" highlight the '+' and '-' and ':' separators
22syn match skhdOperator /->/
23syn match skhdOperator /[+:\-;<>,\[\]@~]/
24
25" Hex keycode form: 0x3C etc
26syn match skhdKeycode /\v0x[0-9A-Fa-f]+/
27
28" Keys (a–z, digits, function‐keys, arrows…)
29syn keyword skhdKey
30      \ return tab space backspace escape delete
31      \ home end pageup pagedown insert
32      \ left right up down
33      \ sound_up sound_down mute play previous next rewind fast
34      \ brightness_up brightness_down illumination_up illumination_down
35syn match skhdKey /\vf([1-9]|1[0-9]|20)\>/
36syn match skhdKey /\v\<[A-Za-z0-9]\>/
37
38" The yabai command and its subcommands
39syn match skhdCommand /\<yabai\>\|\<open\>/
40syn match skhdSubCmd   /\<window\>\|\<space\>\|\<display\>/
41
42" ───────────────────────────────────────────────────────────────────
43"  Treat anything after a single “:” (not double‑colon) as bash
44" ───────────────────────────────────────────────────────────────────
45" load Vim’s built‑in shell rules
46syntax include @bash syntax/bash.vim
47
48" After `:` (not `::`) is a bash command, but not when it is preceded by a `\`
49syn region skhdBash
50      \ matchgroup=skhdOperator
51      \ start=/\v(^|[^:])\zs:\s*/
52      \ end=/\v\s*$\ze/
53      \ skip=/\v\\\s*$/
54      \ keepend
55      \ contains=@bash
56
57" ────────────────────────────────────────────────────────────────
58"  Key‑map group definitions and switches
59" ────────────────────────────────────────────────────────────────
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 name
67syn match   skhdGroupDef    /^::\s*\w\+/
68syn match   skhdGroupName   /::\s*\zs\w\+/
69
70" The `<` switch token in lines like
71"   passthrough < cmd + shift + alt - b ; default
72syn match   skhdSwitch      /<\s*/
73
74" The target (or “fall‑through”) group after the semicolon
75"   ... ; default
76syn 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 skhdProcMapBlock
85      \ matchgroup=skhdProcMapDelim
86      \ start=/\v\[\s*$/
87      \ end=/^\s*\]\s*$/
88      \ keepend
89      \ transparent
90      \ contains=skhdProcMapApp,skhdProcMapWildcard,skhdProcMapUnbind,skhdOperator,skhdComment,skhdBash,skhdString
91
92" App name on the left side:  "Google Chrome" :
93syn match skhdProcMapApp /^\s*\zs"[^"]*"\ze\s*:\s*/ contained
94
95" Wildcard entry:  * :
96syn match skhdProcMapWildcard /^\s*\zs\*\ze\s*:\s*/ contained
97
98" Unbind operator on the right side:  "App" ~   or   * ~
99syn match skhdProcMapUnbind /\v^\s*(\"[^"]*\"|\*)\s*\zs\~\ze\s*$/ contained
100
101syn keyword skhdDirective .load .blacklist
102syn match skhdLoadLine /^\s*\.load\>\s\+/ contains=skhdDirective
103
104syn region skhdBlacklistBlock
105      \ start=/^\s*\.blacklist\>\s*\[\s*$/
106      \ end=/^\s*\]\s*$/
107      \ keepend
108      \ contains=skhdDirective,skhdComment,skhdString
109
110syn region skhdString start=/"/ skip=/\\"/ end=/"/
111
112" ────────────────────────────────────────────────────────────────
113"  Linking to standard Vim highlight groups
114" ────────────────────────────────────────────────────────────────
115hi def link skhdComment    Comment
116hi def link skhdHeadline   Title
117hi def link skhdModifier   Keyword
118hi def link skhdOperator   Operator
119hi def link skhdWildcard     Special
120hi def link skhdKey        Identifier
121hi def link skhdKeycode      Number
122hi def link skhdCommand    Function
123hi def link skhdSubCmd     Statement
124hi def link skhdGroupDef      Label
125hi def link skhdGroupName     Identifier
126hi def link skhdSwitch        Operator
127hi def link skhdTargetGroup   Type
128hi def link skhdString String
129
130hi def link skhdProcMapDelim   Operator
131hi def link skhdProcMapApp     Type
132hi def link skhdProcMapWildcard Special
133hi def link skhdProcMapUnbind  Special
134
135hi def link skhdDirective PreProc
136
137let b:current_syntax = "skhd"