mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-19 15:18:40 +01:00
feat(hotkeys): read an skhdrc
komorebi for Mac's users bind komorebic in an skhdrc, so that is the first file the crate reads. `skhd::parse` reads the whole syntax into the model: bindings with every modifier skhd has, literal keys and macOS keycodes, mode declarations (with `@` and an entry command), mode switches and bindings in one or more modes, per-application lists with `~` and `*`, `.blacklist`, and skhd.zig's `.define` command templates and application groups, which are expanded where they are used. A mode may be used before it is declared, so bindings are put in their modes at the end of the file. Reading never fails. Text that is not valid skhd is an error with its span and is skipped, up to the end of the line or of the list it opened, and reading goes on. What is valid but not realized the way skhd does it has a warning that says so: side-specific modifiers are the modifier, a capturing mode lets unbound keys through, `->` does not pass the key on, and `fn`, `.load`, `.alias`, key forwarding and key sequences are left out. Comments, continued lines and the line numbers of diagnostics are shared with the readers that follow. The tests cover the modifiers, macOS keycodes and the shifted symbol rule, comments and continued lines, modes, lists, defines, spans and recovery after an error, and the corpus test now checks that every skhdrc fixture reads into the keymap of its case. The keymaps of the other cases are written down too, for the readers to be written against.
This commit is contained in:
1 parent
0520068b48
commit
ecf91f077f
8 files changed
+1806
-7
No files matched your search
@@ -708,3 +708,15 @@ derives for the enum is an object with a `Placement` or an `Index` key, which th
|
||||
`JsonSchema` impl of [`PlacementTarget`](../../komorebi/src/core/mod.rs) calls "not what
|
||||
`Serialize` and `Deserialize` read and write". The schema `schema.json` has says a name, a number,
|
||||
or text that is a number, which is also what the module's typed `config` takes.
|
||||
|
||||
## Why are the key binding files read by parsers written for komorebi?
|
||||
|
||||
All three formats, skhd's, whkd's and sxhkd's, are read by parsers written by hand in
|
||||
`komorebi-hotkeys`. For whkd there is a Rust parser, `whkd-parser`, under the same license
|
||||
as komorebi, but it requires a `.shell pwsh|powershell|cmd` line, panics in `Shell::from` on
|
||||
any other shell, and its per-application bindings match Windows process names. For skhd and
|
||||
sxhkd the reason is not recorded; this entry needs one.
|
||||
|
||||
What is not plain syntax is expanded while the file is read: skhd's `.define` templates and
|
||||
application groups are replaced where they are used, so the model has only expanded bindings
|
||||
in it.
|
||||
Reference in new issue
Block a user