Groovy-Emacs-Modes / groovy-emacs-modes

A groovy major mode, grails minor mode, and a groovy inferior mode.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Closure indentation on 20170808.1211

jordi-chacon opened this issue · comments

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
            }
    }
}

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.

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

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

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

commented

(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?