Devicetree formatting configuration #79
nickcoutsos
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Relating to zmkfirmware/zmk#583.
Since switching from generating a new
.keymap
file on commit to editing the Devicetree code in an existing file, I've started applying some generic formatting rules to help with consistency. Some of these rules are pretty agreeable like "don't try to format the contents of integer cell arrays when they span multiple lines" (because this is how layer bindings are expressed and special formatting is applied here already as a core feature of this app), but I expect people to have lots of opinions about other ones.Current experimental configuration:
indent
-- the text to insert for each level of indentation such as the default four-space indent (" "
) or a hard-tab ("\t"
). Trusting you to not do something goofy and break your own keymap.multilineIntegerCellsIndent
-- how to handle indentation of values like layer bindings. This won't affect alignment of the binding cells relative to one another, but whether the common indentation should match the node's depth or if the indentation should be removed (this can help to avoid text wrapping for long-ish lines). Options here are:"reindent"
: apply the level of indentation appropriate for the node's depth"dedent"
: remove any indentation from these lines"keep"
(default): don't make any changes. Because this mainly applies to layer bindings which are already indented by the layout code this doesn't have much effect.Example usage in zmk-config-corne-demo
Potential additional configuration:
¯o_tap
and others) separately from others, and then for readability I split each "group" of integer cells onto its own line. This is all well and good for macros but this part of the formatter is agnostic of ZMK so it applies to any property with multiple integer cells values (e.g.foo = <1 2>, <3 4>;
vsfoo = <1 2 3 4>;
). Maybe this could be refined with a rule about the overall length of the values.I'd be very interested from hearing other thoughts on this.
Beta Was this translation helpful? Give feedback.
All reactions