cmake_format icon indicating copy to clipboard operation
cmake_format copied to clipboard

Add `continuation_mode` configuration option

Open CJKay opened this issue 5 years ago • 3 comments

This commit adds the continuation_mode configuration option, which is used to control the indentation style for continuation lines. At present, upstream is locked to the align style defined by this commit, and this default is maintained.

This new configuration option has two modes:

  • align: The default style, which aligns continuation lines with their parent items.
  • indent: Indents continuation lines according to the tab_size option.

CJKay avatar Sep 08 '20 20:09 CJKay

Hi, thanks for the contribution!

I think the layout model is a little different than you've understood it. This acts a little bit like cmake-format did in it's first version, which turned out to be quite problematic in a lot of edge cases. I think that what you want can be achieved by a combination of an existing feature (modify layout_passes=) and a small feature that has been requested several times but has yet to be implemented (let's call it unwrap-designated-first-argument).

I will follow up with more details when I have more time to describe the issues further. I just wanted to give a justification for why I'm not going to merge this right away.

cheshirekow avatar Sep 08 '20 21:09 cheshirekow

Hi, thanks for the contribution!

I think the layout model is a little different than you've understood it. This acts a little bit like cmake-format did in it's first version, which turned out to be quite problematic in a lot of edge cases. I think that what you want can be achieved by a combination of an existing feature (modify layout_passes=) and a small feature that has been requested several times but has yet to be implemented (let's call it unwrap-designated-first-argument).

I will follow up with more details when I have more time to describe the issues further. I just wanted to give a justification for why I'm not going to merge this right away.

Hiya, thanks for your feedback.

I've tried a number of combinations of layout_passes to no avail, beginning with the simple solution given by #93. Unfortunately, I've been unable to find a way to combine layout passes in such a way that it doesn't bork all sorts of other incidental constructs (particularly if and foreach(x IN LISTS y)), whereas the change offered in this PR failed to reveal any issues in some 3,000 lines of fairly complex CMake (before/after compared, of course).

If there's a way to do this on stable I'd love to know - I find the current setting can cause some very ugly multi-line statements.

CJKay avatar Sep 08 '20 21:09 CJKay

If there's a way to do this on stable I'd love to know - I find the current setting can cause some very ugly multi-line statements.

Can you provide an example?

blackliner avatar Sep 24 '20 10:09 blackliner