The formatting of custom languages does not work properly if the language defines its own set of whitespace tokens instead of using
TokenType.WHITE_SPACE. The result is a very odd behavior of the formatter that is extremely hard to track down, especially because the language API (com.intellij.lang.ParserDefinition#getWhitespaceTokens) tricks one into thinking that using custom whitespace tokens is supported.
This should at least be very well documented (both in the formatter and the ParserDefinition) - I just spent a night trying to get some simple indentation to work until I found out that TokenType.WHITE_SPACE has a special meaning to the code formatter.