casey / just

🤖 Just a command runner
https://just.systems
Creative Commons Zero v1.0 Universal
17.6k stars 399 forks source link

Format request: Align variables that are next to each other #1962

Open nogweii opened 2 months ago

nogweii commented 2 months ago

Given the following example Justfile:

version := "0.2.7"
foo1    := / "tmp"
foo2_3 := "a/"
foo2_bar  := "a/"

tmpdir      := `mktemp`
project_tardir := tmpdir / "awesomesauce-" + version
prj_tarball := tardir + ".tar.gz"

Current Behavior

When you run just --unstable --format --check you get this diff, where every variable only has a single space around the assignment operator and the blank line between them removed:

 version := "0.2.7"
-foo1    := / "tmp"
+foo1 := / "tmp"
 foo2_3 := "a/"
-foo2_bar  := "a/"
-
-tmpdir      := `mktemp`
+foo2_bar := "a/"
+tmpdir := `mktemp`
 project_tardir := tmpdir / "awesomesauce-" + version
 prj_tarball := project_tardir + ".tar.gz"

Wanted Behavior

My preference would be to have the formatted output preserve the blank line and add spacing to the left of the operator to visually align them vertically, resulting in the following:

version  := "0.2.7"
foo1     := / "tmp"
foo2_3   := "a/"
foo2_bar := "a/"

tmpdir         := `mktemp`
project_tardir := tmpdir / "awesomesauce-" + version
prj_tarball    := project_tardir + ".tar.gz"

Where each blank-separated block of variables has it's own alignment, and there are n spaces to cause the := to be vertically aligned.

(Just version 1.25.2 on MacOS)