Repository navigation
build(fmt): format Odin and C/C++ to one style — tabs, 120 columns - #504
Merged
Merged
Conversation
- odinfmt.json: tabs (width 4), 120 columns, sorted imports. Applied to cmd/lava, pkg/jsc, pkg/runtime and pkg/std/sqlite. - .clang-format: the owner's C/C++ style with tabs (width 4) and 120 columns. Applied to pkg/jsc/jsc_init_windows.cpp; vendored picohttpparser opts out. - `make fmt` runs odinfmt (when ODINFMT points at it — it ships with the OLS extension), strip-semicolon, then clang-format. - CLAUDE.md §4: the formatters, and the declaration order (imports, constants, types, procedures), which no formatter enforces. The same configuration Larva adopted in x-ror/larva#71. Formatting only. Checked: `make check` (all three targets), `make build`, a `lava eval` touching timers, microtasks, URL and require; every mutation-manifest `find` still matches exactly once. No tests run: paused for this phase. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The owner's rules, now in CLAUDE.md §4 and applied by `make fmt`:
- `if` always has braces, on their own lines: no `if x do y`, no `if x {y}`.
odinfmt's convert_do (odinfmt.json) and clang-format's InsertBraces
(.clang-format) add the braces; scripts/fmt-if.mjs spreads the one-line
blocks odinfmt leaves behind.
- A blank line before and after every `if` statement, unless it opens or
closes a block or a case; a comment directly above belongs to the if. No
formatter does this, so scripts/fmt-if.mjs does. It tracks strings, comments
and Odin's multi-line raw strings, so embedded JS in the tests is untouched.
Applied to cmd/lava, pkg/jsc, pkg/runtime and pkg/std/sqlite; `make fmt` is
stable on the result (a second run changes nothing). Nine mutation-manifest
entries pointed at `if … do` lines and were retargeted to the same code in its
new form; every find matches exactly once.
Formatting only. Checked: `make check` (all three targets), `make build`, and a
`lava eval` touching nextTick, microtasks, timers, URL, Buffer and require. No
tests run: paused for this phase.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
Pushed 854ca75: two more of the owner's rules, in
The diff is large (about 6,000 added lines), almost all of it braces and blank lines. Nine mutation-manifest entries pointed at Checked: |
This was referenced Nov 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
odinfmt.json: tabs (width 4), 120 columns, sorted imports. Applied tocmd/lava,pkg/jsc,pkg/runtimeandpkg/std/sqlite: 62 files, mostly short calls and signatures joined onto one line and struct fields re-aligned..clang-format: the owner's C/C++ style with tabs (width 4) and 120 columns. Applied topkg/jsc/jsc_init_windows.cpp; vendoredpicohttpparseropts out with its own.clang-format.make fmtruns odinfmt (whenODINFMTpoints at it; it ships with the OLS editor extension and is not on PATH by default), thenodin strip-semicolon, then clang-format.CLAUDE.md§4 names the formatters and the declaration order: imports, constants, types, procedures. No formatter reorders declarations, so that part is a convention.The same configuration Larva adopted in x-ror/larva#71.
Not formatted
100 Odin lines are still longer than 120 columns. odinfmt does not break string literals, comments or foreign declarations; they are left as they are.
Checked
make check(linux, windows and darwin front-ends) andmake build.lava evaltouching timers, microtasks,URLandrequire.findintests/mutation-manifest.jsonstill matches exactly once, so no recorded mutation went stale.No tests and no gates were run, on the owner's instruction for this phase. Formatting only: no behavior change intended, but 62 files changed without a test run.
🤖 Generated with Claude Code