Support for coding styles and "swift-format" tool


(Vincent Coetzee) #1

+1

I also hate the K&R brace style. Really want the ability to customize the formatting of Swift code.

···

On 16 May 2016, at 22:42, Daniel Martín via swift-evolution <swift-evolution@swift.org> wrote:

As Swift is getting traction in more and more platforms outside of Apple, we can expect that many coding styles different from what Apple imposes with SourceKit's indenting rules will emerge. According tohttps://bugs.swift.org/browse/SR-146, we now have decoupled indenting logic from SourceKit into its own library, and a "swift-format" tool is in the making.

I am working on adding support for different coding styles to libIDE. For example, with my changes you could decide how a case label should be indented with respect to its parent switch context, among other things. The current, hard coded indenting decisions in libIDE could be named the "Apple" style, just like Clang supports Google, LLVM, Mozilla, coding styles for C++. Also, this is something that can be supported by external tools like Xcode quite easily.

Do you think this is a good feature to have?

--
Daniel Martín

Vince Coetzee


(Krystof Vasa) #2

Definitely +1.

I've had a long discussion about this from one of the Xcode developers a few months back, pointing out that given how long has Xcode been around it has really really poor support for customizing the codestyle.

I really like what AppCode from JetBrains does - it allows you to even apply the code style automatically on save and allows you to customize it and have teams share the code style - something like StyleCop in C# (though I've never used it).

I do use Swimat (Xcode plugin) fairly often, which enforces spaces between operators, etc.

I've also tried out tailor (https://tailor.sh <https://tailor.sh/>) which is fairly nice, but can be too strict at times.

···

On May 18, 2016, at 5:39 PM, Vincent Coetzee via swift-evolution <swift-evolution@swift.org> wrote:

+1

I also hate the K&R brace style. Really want the ability to customize the formatting of Swift code.

On 16 May 2016, at 22:42, Daniel Martín via swift-evolution <swift-evolution@swift.org> wrote:

As Swift is getting traction in more and more platforms outside of Apple, we can expect that many coding styles different from what Apple imposes with SourceKit's indenting rules will emerge. According tohttps://bugs.swift.org/browse/SR-146, we now have decoupled indenting logic from SourceKit into its own library, and a "swift-format" tool is in the making.

I am working on adding support for different coding styles to libIDE. For example, with my changes you could decide how a case label should be indented with respect to its parent switch context, among other things. The current, hard coded indenting decisions in libIDE could be named the "Apple" style, just like Clang supports Google, LLVM, Mozilla, coding styles for C++. Also, this is something that can be supported by external tools like Xcode quite easily.

Do you think this is a good feature to have?

--
Daniel Martín

Vince Coetzee
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution