NixOS/nixfmt

Multiple `with` should maintain consistent indentation

spikespaz opened this issue · 1 comments

Description

When multiple with are used, they should be kept on the same line (if under soft break) or indented on their own new lines (if longer than soft break).

If the withs are short enough to be on the same line as the assignment operator, they should maintain position. If any are too long, or if they are too long combined, separate them with newlines and keep them on the same indentation (newline following assignment operator).

Small example input

{
  programs.vscode.extensions = with pkgs.vscode-marketplace; with pkgs.vscode-marketplace-release; [
    mads-hartmann.bash-ide-vscode
    timonwong.shellcheck
    foxundermoon.shell-format
  ];
}

Expected output

My preference

{
  programs.vscode.extensions =
	with pkgs.vscode-marketplace;
    with pkgs.vscode-marketplace-release; [
      mads-hartmann.bash-ide-vscode
      timonwong.shellcheck
      foxundermoon.shell-format
    ];
}

Otherwise

{
  programs.vscode.extensions =
	with pkgs.vscode-marketplace;
    with pkgs.vscode-marketplace-release;
    [
      mads-hartmann.bash-ide-vscode
      timonwong.shellcheck
      foxundermoon.shell-format
    ];
}

Actual output

{
  programs.vscode.extensions = with pkgs.vscode-marketplace;
    with pkgs.vscode-marketplace-release; [
      mads-hartmann.bash-ide-vscode
      timonwong.shellcheck
      foxundermoon.shell-format
    ];
}

Should be fixed now