Remix.run Logo
thechao 8 hours ago

I just built a C++ formatter that does this (owned by my employee, unfortunately). There's really only two formatting objects: tab-aligned tables, and single line rows. Both objects also support a right-floating column/tab aligned "//" comment.

Both objects desugar to a sequence of segments (lines).

The result is that you can freely mix expression/assignment blocks & statements. Things like switch-case blocks & macro tables are suddenly trivial to format in 2d.

Because comments are handled as right floating, all comments nicely align.

I vibe coded the base layer in an hour. I'm using with autogenerated code, so output is manually coded based on my input. The tricky bit would be "discovering" tables & block. I'd jus use a combo of an LSP and direct observation of sequential statements.

marxisttemp 7 hours ago | parent [-]

You built it, but your employee owns it? That sounds highly unusual.

thechao 4 hours ago | parent | next [-]

Autocorrect — employer. Too late to change, now!

jtbayly 6 hours ago | parent | prev | next [-]

Probably a single-letter typo. Makes complete sense if changed to “employer.”

pona-a 6 hours ago | parent | prev [-]

Auto corrected employer?