SE-0250: Swift Code Style Guidelines and Formatter

I'm +1 on a default Swift style but -1 on swift-format as the tool to implement it.

Overall I would like to see some set of styling integrated into Swift's tooling, both in the hope that Xcode might finally have configurable formatting, and in the more general desire that we can develop Swift on all platforms with consistent formatting. I would hope that such a formatter could integrate with the upcoming LSP implementation so that formatting can be separated from the editors used to write Swift.

I also think some common styling defaults where not everything is configurable could be fine, if the community can approximate some sort of consensus about them. It makes sense to me that there would be some formatting rules which are configurable (line length, function wrapping behavior) and some that aren't (brace placement, colon placement). We'll see how that discussion goes. Like @anandabits, I anticipate quite the discussion.

However, as it stands right now, swift-format is the inferior formatting tool and I'd rather see a community tool integrated instead of a lesser but Apple blessed tool. Most notably, the use of a JSON configuration file is both a poor choice from a user perspective (JSON is a pain to write by hand and is really only better than XML for config files) as well as the long term flexibility of the project (JSON types are inherently limited). I also find it funny that, at least for now, it's not the best performer, despite the proposal's claims. If adopting a community tool is impossible for some reason, at least adopting YAML or TOML for the config file would make it more acceptable to me. Then we just need to hash out the actual styling.

3 Likes