How to configure code style for Scala in IntelliJ IDEA
Asked Answered
F

1

7

IntelliJ formats my test code like this:

  test("a configuration without classpath to analyze is not valid") {
                                                                  Configuration(
                                                                    None,
                                                                    Seq(),
                                                                    Seq(),
                                                                    Map(),
                                                                        Some(PrintConfiguration(print = Always("output")))
                                                                  ) should not be ('valid)
                                                                }

I hope we all agree that this is a rather stupid way to do this.

How can I configure IntelliJ in so that it moves Configuration and everything belonging to it over to the left, two spaces indented relative to test?

To clarify: most of the code gets indented properly, just code blocks in curly braces, that are parameters get aligne relative to the opening curly brace, not relative to the beginning of the function call.

Forepaw answered 2/4, 2015 at 5:51 Comment(0)
S
8

How about Settings -> CodeStyle -> Scala:

enter image description here

Also make sure to remove the "align when multiline settings" or set the "Do not align block expression parameters" on the Wrapping and Braces tab.

Saltarello answered 2/4, 2015 at 8:25 Comment(4)
Ok, I found the settings for scala, thx for that. I was searching for formatting and didn't realize this was hiding the scala option. But I have the settings just as your screenshot, and it works for most stuff, but not for the parameters that are blocksForepaw
you may see your code at my screenshot and it works fine, it also works fine inside the regular editor (and inside some other class) for me. You may also try to reset your settings by choosing "default" scheme. I use Intellij IDEA 13.1.2 Community Edition.Saltarello
I updated your answer, because it actually lead me to the solution. Thx.Forepaw
I think the formatting preview is of, because the code is only part of class.Forepaw

© 2022 - 2024 — McMap. All rights reserved.