I wander is there a JSON schema for Karabiner configs? This could tremendously improve experience of editing config files in modern code editors (Webstorm, VSCode, etc.) and simplify validation of those configs.
Yep, you can find a JSON file ~/.config/karabiner named karabiner.json, and you can update your settings by modifying this file directly.
It is not what I am looking for. I want a JSON-schema, not a config in a
JSON format.
On Wed, Aug 7, 2019, 04:54 LvChengbin notifications@github.com wrote:
Yep, you can find a JSON file ~/.config/karabiner named karabiner.json,
and you can update your settings by modifying this file directly.—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/tekezo/Karabiner-Elements/issues/1918?email_source=notifications&email_token=AB5T3HEWEFWERVWMNTKIGS3QDITO3A5CNFSM4IDTMRQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3W6NWQ#issuecomment-518907610,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AB5T3HEZVH4NBO3SSBKSD2LQDITO3ANCNFSM4IDTMRQQ
.
It's in the reference manual of the website.
https://pqrs.org/osx/karabiner/json.html#typical-complex_modifications-examples-disable-command-l-on-finder
Sure, I know where the manual is, but it is not what I was looking for.
I think it might be possible to create a validator for the JSON from the API specs on the json.html page.
A static "schema" like XML uses might not be very useful since the JSON structure can change as the program changes, and it would be a lot of extra effort for Karabiner-Elements to parse the schema version and behave differently or throw special warnings if the schema isn't valid, where now I believe it probably just ignores elements it doesn't understand and uses the rest that it does.
Now if you just wanted auto-complete/intellisense, a kind of syntax highlighting and keyword validation might be more useful, and possible to automate given the rules on that page.
I recommend using generator to make such a huge json.
About linter, karabiner_cli works as linter.
Distributed complex_modifications are checked by the linter.
https://github.com/pqrs-org/KE-complex_modifications/
For example, we can check docs/json/personal_tekezo.json in above repository by the following command.
'/Library/Application Support/org.pqrs/Karabiner-Elements/bin/karabiner_cli' \
--lint-complex-modifications \
docs/json/personal_tekezo.json
Thanks for your answers and especially for the handy linting command!
Most helpful comment
I recommend using generator to make such a huge json.
About linter, karabiner_cli works as linter.
Distributed complex_modifications are checked by the linter.
https://github.com/pqrs-org/KE-complex_modifications/
For example, we can check
docs/json/personal_tekezo.jsonin above repository by the following command.