Home > Enterprise >  Custom language plugin - braces alignment when returning an object
Custom language plugin - braces alignment when returning an object

Time:01-29

I am developing a plugin for IntelliJ IDEA which supports my custom Lua-based language formatting.

I expect to get following result

func () {
    //do something
    return {
        data = {
            v1 = "some value",
            v2 = 123
        }
    }
}

But I am getting this:

func () {
    //do something
    return {
            data = {
                       v1 = "some value",
                       v2 = 123
                   }
            }
}

The issue is that the closing braces after return statement are getting aligned with the opening. To align braces in a Java style I tried most obvious combinations of indents and wrappings but with no luck.

I have not implemented any Code Style Settings for my language but when debugging I see that CommonSettings contains HTML, XML, JAVA and JSON CommonCodeStyleSettings. Cleaning up myCommonSettingsMap and myCustomSettingsMap in bebugger did not remedy the situation.

I assume some default settings are involved but I have no idea what to check. Could somebody help me?

CodePudding user response:

I have found the answer at IntelliJ forum: How to make the Indent relative to direct parent's parents?

In my code I always used a default Alignment:

Block block = new Simplek(child, Wrap.createWrap(WrapType.NONE, false), 
                  Alignment.createAlignment(), spacingBuilder);

The solution is to pass null when alignment is not needed.

  • Related