Opening this issue to see if there is demand for a PR that integrates auto-formatting of Devicetree files (dts, dtsi, overlay, keymap) using dts-linter.
Background
dts-linter is the CLI frontend to dts-lsp. Both projects are quite new and explicitly tailored towards zephyr Devicetree files. By default, the formatting adheres to the Zephyr's Devicetree styleguide. The project maintainer @kylebonnici and I have worked together for the past weeks to fix various bugs in the LSP that prevented it from running on the ZMK codebase (okay, it was mainly Kyle doing the fixing), as well as add a few customization flags to the CLI frontend needed for ZMK.
Suggested plan
If those sound like useful additions, I'd be happy to draft PRs to implement any that make sense.
Open questions
-
Formatter setup: dts-linter allows for a few custom settings. Do the following make sense?
- Indent with spaces using 4 spaces
- Max linewidth of 120 (except when guarded with
dts-format off)
- Otherwise apply the Zephyr Style
-
Formatting fences: If reformatting of the existing codebase is desired, what should be fenced off?
- Keymap
bindings if currently manually aligned (yes?)
bindings for 2x2 test keymaps (no?)
- Matrix transform
maps if currently manually aligned (??)
- Physical layout
keys if w, h, x, y, rot, rx, ry is aligned (yes?)
- Anything else?
-
Config file: dts-linter currently doesn't have the option to add a configuration file. This isn't a problem for the pre-commit hook or when configuring the LSP through the editor, but for local development on the CLI it's a nuisance. We can either try to convince @kylebonnici to add a config option or add a small shell-wrapper to the zmk repo that calls dts-linter with the appropriate CLI args.
Diff against current codebase
https://github.com/zmkfirmware/zmk/compare/main...urob:zmk:dts-linter-diff?expand=1
A few observations:
- Manual aligned arrays require
dts-format off fences (see above)
- Lack of placement formatting for in-line comments. Mainly a consistency issue?
- Lot's of changes due to applying the Zephyr Style Guide (I find them largely sensible)
Related
Opening this issue to see if there is demand for a PR that integrates auto-formatting of Devicetree files (dts, dtsi, overlay, keymap) using
dts-linter.Background
dts-linteris the CLI frontend todts-lsp. Both projects are quite new and explicitly tailored towardszephyrDevicetree files. By default, the formatting adheres to the Zephyr's Devicetree styleguide. The project maintainer @kylebonnici and I have worked together for the past weeks to fix various bugs in the LSP that prevented it from running on the ZMK codebase (okay, it was mainly Kyle doing the fixing), as well as add a few customization flags to the CLI frontend needed for ZMK.Suggested plan
bindings,mapand a few others) withdts-format off(if reformatting of the existing codebase is desired)zmkfirmwareorkylebonniciif desired.If those sound like useful additions, I'd be happy to draft PRs to implement any that make sense.
Open questions
Formatter setup:
dts-linterallows for a few custom settings. Do the following make sense?dts-format off)Formatting fences: If reformatting of the existing codebase is desired, what should be fenced off?
bindingsif currently manually aligned (yes?)bindingsfor 2x2 test keymaps (no?)maps if currently manually aligned (??)keysifw, h, x, y, rot, rx, ryis aligned (yes?)Config file:
dts-lintercurrently doesn't have the option to add a configuration file. This isn't a problem for thepre-commithook or when configuring the LSP through the editor, but for local development on the CLI it's a nuisance. We can either try to convince @kylebonnici to add a config option or add a small shell-wrapper to thezmkrepo that callsdts-linterwith the appropriate CLI args.Diff against current codebase
https://github.com/zmkfirmware/zmk/compare/main...urob:zmk:dts-linter-diff?expand=1
A few observations:
dts-format offfences (see above)Related