Groovy-Emacs-Modes / groovy-emacs-modes

A groovy major mode, grails minor mode, and a groovy inferior mode.
84 stars 39 forks source link

Closure indentation on 20170808.1211 #83

Closed jordi-chacon closed 5 years ago

jordi-chacon commented 7 years ago

This is how 20170808.1211 currently indents closures:

class A {
    def foo() {
        [1, 2, 3]
            .findAll {
            it % 2 == 0
        }
            .collect { it ->
            it + 1
        }
    }
}

And I would say this is how it should be:

class A {
    def foo() {
        [1, 2, 3]
            .findAll {
                it % 2 == 0
            }
            .collect { it ->
                it + 1
            }
    }
}
Wilfred commented 7 years ago

This is actually the same issue as #61, but I've decided to close that big issue in favour of this one, which is smaller and clearer.

Wilfred commented 7 years ago

(The issue here is that we don't always consider .foo to increase the indentation depth. This breaks nested .foo too.)

mariogarcia commented 6 years ago

Anything new on this ? I'm suffering this problem too.

Wilfred commented 6 years ago

I'm not writing as much groovy these days, but PRs welcome :)

haqle314 commented 5 years ago

(The issue here is that we don't always consider .foo to increase the indentation depth. This breaks nested .foo too.)

I don't have much experience with Groovy so I'm not sure what you're talking about here. Could you give some example code for the cases you mentioned? As far as I understand, just adding 1 indentation level when the current line has .foo { but no matching } should suffice, correct?