Swift source code formatting tool like clang-format for objective-c


(Håkon Bogen) #1

I'm a huge fan of clang-format, (http://clang.llvm.org/docs/ClangFormat.html)
a tool that can set rules for formatting source code in Objective-C
projects. With tools like spacecommander (
https://github.com/square/spacecommander) and clang-format for XCode (
https://github.com/travisjeffery/ClangFormat-Xcode), it can enforce the
rules and auto run the formatter constantly so nicely formatted code stays
that way. It saves alot of time, and keeps acleaner commit log without
constant formatting adjustment.

Moving to Swift, it was a dearly missed feature. I actually asked about if
Swift would be supported by clang-format on the clang-developers forum
after it was announced in 2014, but got no replies. (
http://clang-developers.42468.n3.nabble.com/Will-clang-format-support-the-format-of-Swift-td4039910.html
)

Would auto formatting tools for Swift be a good idea to include in the
bundle of Swift Components, like clang-format is a part of clang/llvm?

···

--
Regards Håkon Bogen
http://haaakon.org
+47 95 09 68 11


(Douglas Gregor) #2

This would be a fantastic thing to have, but of course someone has to build it :wink:

  - Doug

···

On Dec 10, 2015, at 11:13 AM, Håkon Bogen via swift-evolution <swift-evolution@swift.org> wrote:

I'm a huge fan of clang-format, (http://clang.llvm.org/docs/ClangFormat.html) a tool that can set rules for formatting source code in Objective-C projects. With tools like spacecommander (https://github.com/square/spacecommander) and clang-format for XCode (https://github.com/travisjeffery/ClangFormat-Xcode), it can enforce the rules and auto run the formatter constantly so nicely formatted code stays that way. It saves alot of time, and keeps acleaner commit log without constant formatting adjustment.

Moving to Swift, it was a dearly missed feature. I actually asked about if Swift would be supported by clang-format on the clang-developers forum after it was announced in 2014, but got no replies. ( http://clang-developers.42468.n3.nabble.com/Will-clang-format-support-the-format-of-Swift-td4039910.html )

Would auto formatting tools for Swift be a good idea to include in the bundle of Swift Components, like clang-format is a part of clang/llvm?


(Håkon Bogen) #3

Thanks for the feedback! I've actually started experimenting on building a
Swift Formatter that uses the output from SourceKit gotten from
SourceKitten to autoformat Swift code (https://github.com/jpsim/SourceKitten
).

My understanding is that SourceKit still will deliver the syntax data even
if it's internally moved to libIDE. Not familiar with libIDE yet so if
anyone knows if it will differ from what SourceKit outputs, just give me a
heads up.

···

2015-12-10 20:25 GMT+01:00 Johan Jensen <jj@johanjensen.dk>:

I think it is planned, but someone has to build it:

https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151207/000160.html

—Johan

On Thu, Dec 10, 2015 at 8:13 PM, Håkon Bogen <swift-evolution@swift.org> > wrote:

I'm a huge fan of clang-format, (
http://clang.llvm.org/docs/ClangFormat.html) a tool that can set rules
for formatting source code in Objective-C projects. With tools like
spacecommander (https://github.com/square/spacecommander) and
clang-format for XCode (
https://github.com/travisjeffery/ClangFormat-Xcode), it can enforce the
rules and auto run the formatter constantly so nicely formatted code stays
that way. It saves alot of time, and keeps acleaner commit log without
constant formatting adjustment.

Moving to Swift, it was a dearly missed feature. I actually asked about
if Swift would be supported by clang-format on the clang-developers forum
after it was announced in 2014, but got no replies. (
http://clang-developers.42468.n3.nabble.com/Will-clang-format-support-the-format-of-Swift-td4039910.html
)

Would auto formatting tools for Swift be a good idea to include in the
bundle of Swift Components, like clang-format is a part of clang/llvm?

--
Regards Håkon Bogen
http://haaakon.org
+47 95 09 68 11

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

--
Hilsen Håkon Bogen
http://haaakon.org
+47 95 09 68 11


(James Campbell) #4

You guys should check out HoundCI it has swift support!

···

On Fri, Dec 11, 2015 at 9:58 AM, Håkon Bogen <swift-evolution@swift.org> wrote:

Thanks for the feedback! I've actually started experimenting on building a
Swift Formatter that uses the output from SourceKit gotten from
SourceKitten to autoformat Swift code (
https://github.com/jpsim/SourceKitten).

My understanding is that SourceKit still will deliver the syntax data even
if it's internally moved to libIDE. Not familiar with libIDE yet so if
anyone knows if it will differ from what SourceKit outputs, just give me a
heads up.

2015-12-10 20:25 GMT+01:00 Johan Jensen <jj@johanjensen.dk>:

I think it is planned, but someone has to build it:

https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151207/000160.html

—Johan

On Thu, Dec 10, 2015 at 8:13 PM, Håkon Bogen <swift-evolution@swift.org> >> wrote:

I'm a huge fan of clang-format, (
http://clang.llvm.org/docs/ClangFormat.html) a tool that can set rules
for formatting source code in Objective-C projects. With tools like
spacecommander (https://github.com/square/spacecommander) and
clang-format for XCode (
https://github.com/travisjeffery/ClangFormat-Xcode), it can enforce the
rules and auto run the formatter constantly so nicely formatted code stays
that way. It saves alot of time, and keeps acleaner commit log without
constant formatting adjustment.

Moving to Swift, it was a dearly missed feature. I actually asked about
if Swift would be supported by clang-format on the clang-developers forum
after it was announced in 2014, but got no replies. (
http://clang-developers.42468.n3.nabble.com/Will-clang-format-support-the-format-of-Swift-td4039910.html
)

Would auto formatting tools for Swift be a good idea to include in the
bundle of Swift Components, like clang-format is a part of clang/llvm?

--
Regards Håkon Bogen
http://haaakon.org
+47 95 09 68 11

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

--
Hilsen Håkon Bogen
http://haaakon.org
+47 95 09 68 11

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

--
 Wizard
james@supmenow.com
+44 7523 279 698