You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the same spirit as --width (default 100) allowing end-users outside of nixpkgs to tweak nixfmt's behavior, I'd like an option to disable the default formatting of non-singleton lists.
When the option is enabled, lists of any element count should be rendered on a single line unless that cannot be done for some other reason, such as comments within the list or the total line length being too long.
Better yet, a granular --max-list-items option could be added:
default 1 for the current behavior
0 would always produce a multi-line list
a negative value (-1) would always produce a single-line list (if possible, as described in the rest of this issue).
Any other positive integer would use that value as the threshold for when to no longer attempt to format a list on a single line.
Small example input
{single=["a"];short=["a""b""c"];long=["a very very""long list of""a few elements""with many many""characters!"];shortWithComment=[# Elements"a""b""c"];shortListWithAVeryVeryLongName_LoremipsumdolorsitametconsecteturadipiscingelitPhasellusaliquetutmauriseumollisSuspendisserhoncusdui=["a""b""c"];}
Expected output
{single=["a"];short=["a""b""c"];long=["a very very""long list of""a few elements""with many many""characters!"];shortWithComment=[# Elements"a""b""c"];shortListWithAVeryVeryLongName_LoremipsumdolorsitametconsecteturadipiscingelitPhasellusaliquetutmauriseumollisSuspendisserhoncusdui=["a""b""c"];}
Actual output
{single=["a"];short=["a""b""c"];long=["a very very""long list of""a few elements""with many many""characters!"];shortWithComment=[# Elements"a""b""c"];shortListWithAVeryVeryLongName_LoremipsumdolorsitametconsecteturadipiscingelitPhasellusaliquetutmauriseumollisSuspendisserhoncusdui=["a""b""c"];}
Note: Only the short list and the short list with a long name should be formatted differently when --single-line-lists is used.
Related
This is essentially the opposite of #136 which was asking to revert d2e8575
The text was updated successfully, but these errors were encountered:
MattSturgeon
changed the title
--single-line-lists option to format non-singleton lists on one line where possible
CLI option to format non-singleton lists on one line where possible
Jun 4, 2024
MattSturgeon
changed the title
CLI option to format non-singleton lists on one line where possible
CLI option to format non-singleton lists on one line
Jun 4, 2024
Description
In the same spirit as
--width
(default 100) allowing end-users outside of nixpkgs to tweak nixfmt's behavior, I'd like an option to disable the default formatting of non-singleton lists.When the option is enabled, lists of any element count should be rendered on a single line unless that cannot be done for some other reason, such as comments within the list or the total line length being too long.
Better yet, a granular
--max-list-items
option could be added:Small example input
Expected output
Actual output
Note: Only the
short
list and the short list with a long name should be formatted differently when--single-line-lists
is used.Related
This is essentially the opposite of #136 which was asking to revert d2e8575
The text was updated successfully, but these errors were encountered: