-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Swift format #8610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Swift format #8610
Conversation
@swift-ci please test |
CC: @regnerjr - could you please take a look at the IDE change? |
Build failed |
Build failed |
@swift-ci please smoke test |
CC @jrose-apple |
include/swift/IDE/Formatting.h
Outdated
unsigned IndentWidth = 4; | ||
unsigned TabWidth = 4; | ||
unsigned IndentWidth = 2; | ||
unsigned TabWidth = 8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you asked…please leave these alone. I like your settings better, but the current defaults match what Xcode does by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure if that would be a problem for Xcode, so I figured better to just discuss it :-). What do you think of changing the defaults in swift-format
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a problem for Xcode. I just think the defaults for the command line tool should match the defaults in Xcode.
@@ -158,11 +158,6 @@ class SwiftFormatInvocation { | |||
InputFilenames.push_back(A->getValue()); | |||
} | |||
|
|||
if (InputFilenames.empty()) { | |||
Diags.diagnose(SourceLoc(), diag::error_mode_requires_an_input_file); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah. Most Swift tools use an explicit -
for this. Is accepting input on stdin better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so. It simplifies the integration and matches the behaviour for clang-format.
tools/driver/swift-format.py
Outdated
@@ -0,0 +1,93 @@ | |||
# This file is a minimal swift-format vim-integration. To install: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Historically we've avoided including editor support files in the repo for anything besides syntax coloring, and we definitely aren't calling them supported (as your "file bugs at bugs.swift.org" implies). I think you'd have to ask on swift-dev whether that policy has changed.
(And if it has, this belongs in utils/ rather than tools/driver/, and with "vim" in the name.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can drop the file bugs bit, and move it.
@swift-ci please test |
Build failed |
@jrose-apple ignoring the indentation issue (Ill fix that later) ... is this okay? |
No, please ask Ted on swift-dev if the policy has changed regarding editor support beyond syntax highlighting. |
CC: @tkremenek |
@swift-ci test |
Build failed |
Use `EXIT_SUCCESS` and `EXIT_FAILURE` rather than the raw values. NFC.
We would previously fail to read from stdin as we would diagnose an error if no input files were provided. This allows us to read from stdin once more.
@swift-ci please test |
Build failed |
Build failed |
@swift-ci please test |
Build failed |
Build failed |
Add a helper, based on clang-format.py to integrate swift-format into vim.
@swift-ci please test |
Build failed |
Build failed |
@swift-ci please test macOS platform |
This was discussed on the mailing list and was okayed. @jrose-apple's comments were addressed. |
@compnerd This broke the build slightly. Please don't forget to run pylint next time ;-) |
Perform a couple of small cleanups to the swifft-format tool. The bulk of the changes here are related to the introduction of a small python based wrapper script to aid invoking the swift-format tool from vim. This mirrors the clang-format integration script to integrate swift-format into vim.