Repository navigation
BSN formatter + CLI - #26391
BSN formatter + CLI#26391taboky-dev wants to merge 39 commits into
Conversation
|
Welcome, new contributor! Please make sure you've read our contributing guide, as well as our policy regarding AI usage, and we look forward to reviewing your pull request shortly ✨ |
|
A lot has changed since the previous PR was created, and I am updating this to fit the new BSN changes and keep it up-to-date (as I am in need of a BSN formatter). I will be fixing the CI errors (and formatting bugs), if it is better to move these changes somewhere else, do let me know! EDIT: I just became aware of the existence of the EDIT 2: Just to experiment, I tried to move bsnfmt to |
|
There's also rules that aren't defined yet, for example, how Children with 1 entry or a component with 1 field should be formatted: bsn! {
Node {
width: px(100),
}
Children [
@scene_function()
]
// OR
Node { width: px(100) }
Children [ @scene_function() ]
}Or how dot expressions should be formatted: bsn! {
ComponentA::default().methodA(1.0)
// OR
ComponentA::default()
.methodA(1.0)
// IMO a chain should be formatted like this in either case
ComponentA::default()
.methodA(1.0)
.methodB(true)
.methodC("Hello, World")
}I couldn't find a discussion about this, I am going with what's easiest to implement first as I want to fix the bugs and make this usable. |
|
Awesome! Let us know when this is ready for review. |
Objective
BSN formatter
Solution
Add a formatter for BSN that works with the
bsn!andbsn_list!macros, as well as the upcoming.bsnfile.Testing
There is a small readme with some instructions on how to install and use the CLI.
Notes
bevy fmtcrate inbevy_clibut only if it is a standalone binary because that is fundamentally a requirement for editor workflows (and other things too) imo.synstrips out comments and as far as I know this requires either matching surrounding areas after formatting or changes to the bsn parser itself.Showcase
Recording.2026-03-30.211926.mp4