Skip to content

Commit

Permalink
WIP expand singleton lists again
Browse files Browse the repository at this point in the history
  • Loading branch information
piegamesde committed Oct 10, 2023
1 parent 43dd01d commit 5217131
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 43 deletions.
10 changes: 5 additions & 5 deletions src/Nixfmt/Pretty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,11 @@ prettyTerm (List (Ann leading paropen Nothing) (Items []) (Ann [] parclose trail
prettyTerm (List paropen@(Ann _ _ Nothing) (Items [item@(CommentedItem iComment item')]) parclose@(Ann [] _ _))
= base $ group $
pretty paropen <>
(if isAbsorbable item' && null iComment then
surroundWith hardspace item'
else
surroundWith line $ nest 2 item
)
--(if isAbsorbable item' && null iComment then
-- surroundWith hardspace item'
--else
(surroundWith line $ nest 2 item)
--)
<> pretty parclose

-- General list (len >= 2)
Expand Down
14 changes: 8 additions & 6 deletions test/diff/idioms_lib_4/out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -641,12 +641,14 @@ rec {

androideabi = { };
android = {
assertions = [ {
assertion = platform: !platform.isAarch32;
message = ''
The "android" ABI is not for 32-bit ARM. Use "androideabi" instead.
'';
} ];
assertions = [
{
assertion = platform: !platform.isAarch32;
message = ''
The "android" ABI is not for 32-bit ARM. Use "androideabi" instead.
'';
}
];
};

gnueabi = {
Expand Down
10 changes: 6 additions & 4 deletions test/diff/idioms_lib_5/out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,12 @@ let
typeCheck =
type: value:
let
merged = lib.mergeDefinitions [ ] type [ {
file = lib.unknownModule;
inherit value;
} ];
merged = lib.mergeDefinitions [ ] type [
{
file = lib.unknownModule;
inherit value;
}
];
eval = builtins.tryEval (builtins.deepSeq merged.mergedValue null);
in
eval.success;
Expand Down
24 changes: 14 additions & 10 deletions test/diff/idioms_nixos_2/out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -828,10 +828,12 @@ in
}

{
assertions = [ {
assertion = cfg.database.createLocally -> cfg.config.dbtype == "mysql";
message = "services.nextcloud.config.dbtype must be set to mysql if services.nextcloud.database.createLocally is set to true.";
} ];
assertions = [
{
assertion = cfg.database.createLocally -> cfg.config.dbtype == "mysql";
message = "services.nextcloud.config.dbtype must be set to mysql if services.nextcloud.database.createLocally is set to true.";
}
];
}

{
Expand Down Expand Up @@ -1154,12 +1156,14 @@ in
enable = true;
package = lib.mkDefault pkgs.mariadb;
ensureDatabases = [ cfg.config.dbname ];
ensureUsers = [ {
name = cfg.config.dbuser;
ensurePermissions = {
"${cfg.config.dbname}.*" = "ALL PRIVILEGES";
};
} ];
ensureUsers = [
{
name = cfg.config.dbuser;
ensurePermissions = {
"${cfg.config.dbname}.*" = "ALL PRIVILEGES";
};
}
];
initialScript = pkgs.writeText "mysql-init" ''
CREATE USER '${cfg.config.dbname}'@'localhost' IDENTIFIED BY '${
builtins.readFile (cfg.config.dbpassFile)
Expand Down
34 changes: 21 additions & 13 deletions test/diff/lists/out.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
[
[ {
# multiline
foo = "bar";
foo2 = "barbar";
} ]
[
{
# multiline
foo = "bar";
foo2 = "barbar";
}
]
[
(
if foo then
Expand Down Expand Up @@ -72,14 +74,20 @@
# e
]

[ [
multi
line
] ]
[
[
multi
line
]
]
[ [ [ singleton ] ] ]
[ [ [ { } ] ] ]
[ [ [
{ }
multiline
] ] ]
[
[
[
{ }
multiline
]
]
]
]
12 changes: 7 additions & 5 deletions test/diff/paren/out.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
[
(
done
// listToAttrs [ {
# multline
name = entry;
value = 1;
} ]
// listToAttrs [
{
# multline
name = entry;
value = 1;
}
]
)
]
(
Expand Down

0 comments on commit 5217131

Please sign in to comment.