1

Is there any formatting options available in either ktlint, ktfmt, diktat, prettier or other linter that can help me achieve this (see below)?

This is the format that I desire (rewritten for this purpose, focus on formatting - not the logic):

fun foo() {
    return true && ("aaaaaaaaaaaaaaa" ==
        "ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd")
}

Comment: This style is more compact where I would want a line break if the content doesn't fit and add as many "whole" expressions as possible on the previous line before making the line break

But my lint formatter (ktlint) wants this format:

fun foo() {
    return true && (
        "aaaaaaaaaaaaaaa" ==
        "ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"
    )
}

Comment: An unwanted line break is added right after the left parenthesis

What I have tried: Most options in ktlint that include the keywords "parenthesis", "line break", etc.

My current .editorconfig:

[*]
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[{*.kt,*.kts}]
ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL
ij_kotlin_continuation_indent_in_if_conditions = false
Alix
  • 2,630
  • 30
  • 72

0 Answers0