cheshirekow / cmake_format

Source code formatter for cmake listfiles.
GNU General Public License v3.0
964 stars 106 forks source link

Add `continuation_mode` configuration option #223

Open CJKay opened 4 years ago

CJKay commented 4 years ago

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:

cheshirekow commented 4 years ago

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.

CJKay commented 4 years ago

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.

blackliner commented 4 years ago

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?