Format request: Align variables that are next to each other
- Dominant language
- Rust
- Stars
- 35.8k
- Forks
- 846
- Avg merge
- 27m
- Merged PRs (30d)
- 3
Description
Given the following example Justfile:
```just
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:
```diff
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:
```just
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)*
Contributor guide
Research direction
Start at the formatter entry point used by `just --unstable --format --check`, then trace how variable assignments and blank-separated blocks are formatted. Done means each block aligns its `:=` operators independently, blank lines are preserved, and the example produces the requested output without a formatting diff.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100