cheshirekow / cmake_format

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

Don't touch newlines #246

Open Codym48 opened 3 years ago

Codym48 commented 3 years ago

Is there an option for cmake-format to just leave existing newline characters alone? We'd like to use aspects of the tool to control tabs/spaces, alphabetization of lists, etc., but cannot find suitable settings for other arguments (max_subgroups_hwrap, max_pargs_hwrap, always_wrap, and layout_passes) that produce readable and mergeable code. We'd like to just turn off cmake-format's modification of newlines.

cheshirekow commented 3 years ago

We'd like to just turn off cmake-format's modification of newlines.

Hm... consistent linebraking is the foremost feature of cmake-format and it's raison d'être. There is no feature to turn it off currently. Any re-formatting that changes the relative order of tokens (e.g. sorting alphabetically) might get a little squirly. If cmake-format isn't allowed to choose linebreaks, would you just want to the same set of relative token locations but swap the tokens among those slots, so to speak? If the tokens aren't similar in size something that was "newlined well" will get reformatted into something which is not.

Codym48 commented 3 years ago

The lists we'd like to alphabetize, primarily to reduce merge conflicts, are all vertical lists of files, directories, and other function arguments. As far as I can tell, the only way to guarantee our file lists are laid out vertically is to set both hwrap arguments to 1, which is the "hammer" that indiscriminately destroys the readability of all other statements, like multi-argument if statements.

Many of the issues we see are already described and acknowledged in #174, #138, and #136.

Rather than define rigid wrapping rules and accept continued maintenance burden of custom function configurations and command-specific settings, we'd like to empower the developers to choose the location of newlines, but use a formatter to enforce proper indentation and spacing and ...

This is how we have ArtisticStyle and yapf configured.

This would certainly allow the input file formatting to influence the output. Does that mean it's incompatible with the cmake-format vision?