pinwheel: Write .bsp/pants.json in new worktrees

`.bsp/` is gitignored, so a worktree started without the Pants BSP
connection file. Metals then found no build server, ran `scala-cli
setup-ide` and compiled the whole repo as one Scala 3 project with no
third-party dependencies, so go to definition found nothing and
semanticdb never appeared.

When the primary checkout has `.bsp/pants.json`, `wt` now runs `pants
experimental-bsp` in each worktree it adds, in that worktree's devshell
and without starting a pantsd. The runner script it writes records the
devshell's PATH and the checkout's log path, so it is generated rather
than copied from the primary. When direnv cannot load, as when the
`.envrc` differs from the primary's, `wt` says what to run instead.
This commit is contained in:
Alexander Heldt committed 2026-11-24 17:22:45 +01:00
1 parent 3d2208f432
commit 5207e3e227
1 file changed
+6
+6
View File
@@ -105,6 +105,12 @@ _wt_setup() {
print -r -- "[python-repos] print -r -- "[python-repos]
find_links = [\"file://$primary/dist/\"]" >"$dir/.pants.rc" find_links = [\"file://$primary/dist/\"]" >"$dir/.pants.rc"
fi fi
if [[ -f $primary/.bsp/pants.json && -f $dir/pants.toml ]]; then
print -r -- "wt: writing .bsp/pants.json for Metals"
(cd "$dir" && direnv exec . pants --no-pantsd experimental-bsp) ||
print -u2 "wt: no .bsp/pants.json, so Metals will set up scala-cli here; run" \
"pants --no-pantsd experimental-bsp in the devshell before opening a Scala file"
fi
} }
_wt() { _wt() {