swift-emacs / swift-mode

Emacs support for Apple's Swift programming language.
GNU General Public License v3.0
363 stars 47 forks source link

[Question/Help] - How to configure indentation? #150

Closed IcaroBritto closed 5 years ago

IcaroBritto commented 5 years ago

Hi everyone. I'm really new to the Emacs world and I just started using swift-mode.

I really don't know how to configure the indentation for a specific situation that I'm facing. So the current behavior is this one:

func myFunction() {
    self.performBatchUpdates({
                                 // This is not what I want
                             }) {
        // ...
    }
}

And the behavior that I want is this one:

func myFunction() {
    self.performBatchUpdates({
        // This is what I want
    }) {
         // ...
    }
}

Can anyone help me with that? Thank you!

taku0 commented 5 years ago

swift-mode doesn't support that indentation.

When a method takes multiple functions, I recommend you to pass them with explicit labels:

func myFunction() {
  self.perform(
    batchUpdates: {
      // ...
    },
    completion: {
      // ...
    }
  )
}

Google also recommends so in Google's swift style guide.

IcaroBritto commented 5 years ago

Humm, I see.

Thank you for the replay, by the way :)