nicklockwood / SwiftFormat

A command-line tool and Xcode Extension for formatting Swift code
MIT License
7.63k stars 623 forks source link

Can swiftformat align && operators in multi-line Equatable implementations like Xcode format? #1633

Open topkim993 opened 4 months ago

topkim993 commented 4 months ago

Background Xcode format automatically aligns && operators in multi-line Equatable implementations for better readability:

xcode format

struct Test: Equatable {
    let a: String
    let b: String
    let c: String
    let d: String

    public static func == (lhs: Test, rhs: Test) -> Bool {
        lhs.a == rhs.a &&
        lhs.b == rhs.b &&
        lhs.c == rhs.c
    }
}

However, using swiftformat --indent doesn't apply this alignment

swiftformat --indent

struct Test: Equatable {
    let a: String
    let b: String
    let c: String
    let d: String

    public static func == (lhs: Test, rhs: Test) -> Bool {
        lhs.a == rhs.a &&
            lhs.b == rhs.b &&
            lhs.c == rhs.c
    }
}

Question

Is there a way to configure swiftformat to align && operators in a way that matches Xcode format? If not, are there recommended workarounds or is this a potential feature for future updates?