Integrated code formatter

deadalnix deadalnix at
Tue Jan 18 02:03:32 UTC 2022

On Monday, 17 January 2022 at 21:46:08 UTC, forkit wrote:
> So I use clang-format all the time.
> It makes such a difference, I can't imagine programming without 
> it anymore.
> But D doesn't have something integrated like this.
> I am aware of dfmt.. but even on it's github page it says "dfmt 
> is beta quality."
> I wonder if it isn't time a code formatter for D became a more 
> integrated product, into the release itself, so that people 
> like me can actually rely on it to work as expected, and also, 
> so that the formatter's needs were considered whenever making 
> changes to D.
> Or is D code now so variable and complex, that no formatter can 
> reliably format it?

You might want to have a go at sdfmt.

1/ clone
2/ Go in it and make -j bin/sdfmt
3/ bin/sdfmt -i myfile

It is very much work in progress, but uses an approach similar to 
clang format (contrary to dfmt which IMO uses an approach that 
doesn't lend itself to get the same level of quality).

You'll almost certainly run into weird stuff, and I'd be happy to 
hear about them so they can get ironed out.

More information about the Digitalmars-d mailing list