alejandra icon indicating copy to clipboard operation
alejandra copied to clipboard

Consider less indentation for concatenated values

Open quantenzitrone opened this issue 1 year ago • 0 comments

{
  # why is the formatting like this for concatenated values:
  test =
    {
      foo = "foo";
    }
    // {
      bar = "bar";
    };
  test2 =
    ''
      foo
    ''
    ++ ''
      bar
    '';
  # but like this for let in:
  test3 = let
    foo = "foo";
    bar = "bar";
  in {
    inherit foo bar;
  };
  # ?
}

Some consistency would be nice there:

{

  test = {
    foo = "foo";
  }
  // {
    bar = "bar";
  };
  test2 = ''
    foo
  ''
  ++ ''
    bar
  '';
  test3 = let
    foo = "foo";
    bar = "bar";
  in {
    inherit foo bar;
  };
}

furthermore, if you add something to an existing single value, the diff would be cleaner:

{
  test = {
    foo = "foo";
+ }
+ // {
+   bar = "bar";
  };
}

opposed to:

{
- test = {
-   foo = "foo";
- };
+ test =
+   {
+     foo = "foo";
+   }
+   // {
+     bar = "bar";
+   };
}

obviously, this only applies to stuff that has grouping characters, like:

  • sets
  • Parenthesized function calls
  • lists
  • multiline strings

i am not really sure if and how this would be consistent with stuff that has no grouping characters, but i would also be ok with stuff like this:

let
  bar = ["bar"];
in {
  foobar = [
    "foo"
  ]
  ++ bar;
}

I'm honestly more annoyed by the extra indentation and the almost empty line with [

let
  bar = ["bar"];
in {
  foobar = 
    [
      "foo"
    ]
    ++ bar;
}

quantenzitrone avatar Apr 11 '23 23:04 quantenzitrone