hvesalai / emacs-scala-mode

The definitive scala-mode for emacs
http://ensime.org
GNU General Public License v3.0
361 stars 68 forks source link

fix #120, align according to forms #130

Closed hvesalai closed 7 years ago

hvesalai commented 7 years ago

This needs some testing. It's a clear bug fix but still changes the handling of many things

hvesalai commented 7 years ago

with scala-indent:align-format t

val y = if (x)
          foo
        else
          bar

and else

val y = if (x)
  foo
else
  bar
fommil commented 7 years ago

I like that example. I tend to use scalariform (or scalafmt) as part of my build so unfortunately even if this is prettier than scalariform it won't impact my checked in code... @olafurpg do you have any cool features for this kind of alignment?

olafurpg commented 7 years ago

scalafmt would reformat that as

val y =
  if (x)
    foo
  else
    bar

Scalafmt has lots of alignment goodies but not for if/else.

hvesalai commented 7 years ago

scala-mode doesn't format the code other than indent it. So with the newline between = and if it would do the same as your formatter.

fommil commented 7 years ago

cool, it's good to catch the discrepencies. Once I get used to the auto formatter, I tend to write code that doesn't need to be auto formatted (much)

hvesalai commented 7 years ago

@nloyola heads up, please give this a spin!

nloyola commented 7 years ago

Thanks @hvesalai! It works for me.