derekwyatt / vim-scala

My work on integration of Scala into Vim - not a ton here, but useful for me.
http://derekwyatt.org
Apache License 2.0
1.09k stars 144 forks source link

for loop with multiline iteration has incorrect indention for closing brace #138

Open tmccombs opened 7 years ago

tmccombs commented 7 years ago

If the iteration part of a for loop is multiple lines, for example:

for {
  a <- b
  c <- d
} yield {
   // body
}

then when I type the second opening brace (after yield) it iwll indent the line so the first closing brace lines up with the line before, like:

for {
  a <- b
  c <- d
  } yield {

The same thing happens if the yield isn't there. Strangely , if I don't have the second opening brace the line with the closing brace indents correctly.

stumash commented 3 years ago

this also happens for function definitions, i.e. should do:

def foo(
  i: Int,
  j: Int,
): Int = {
  // body
}

but actually does:

def foo(
  i: Int,
  j: Int,
  ): Int = {
  // body
}

In fact, the exact same problem also exists for function calls, not only function definitions. I.e., it does this:

foo(
  1,
  2,
  ) // should not be indented

I went ahead and looked at indent/scala.vim to propose a fix, but vimscript man... helluva language