Skip to content

fix(zsh): group just -g recipe completion like bare just - #347

Merged
laurigates merged 1 commit into
mainfrom
fix/just-global-flag-completion
Jul 29, 2026
Merged

fix(zsh): group just -g recipe completion like bare just#347
laurigates merged 1 commit into
mainfrom
fix/just-global-flag-completion

Conversation

@laurigates

Copy link
Copy Markdown
Owner

Fixes just -g <TAB> falling back to the flat clap completion.

What

~/.zfunc/_just (source: dot_zfunc/_just) only took its grouped path when the recipe name sat in word 2:

if [[ ${words[CURRENT]} != -* ]] && (( CURRENT == 2 )); then

So just -g <TAB> landed at word 3 and fell through to just's clap dynamic completer, which returns the global recipes flattened into one values group alongside all 68 CLI flags (154 candidates total). fzf-tab rendered that as a single unusable list — no [group(...)] headers, no ,/. group switching.

How

Adds _just_recipe_position, which walks the words before the cursor and accepts a leading run of justfile-selecting flags:

Flag Form
-g / --global-justfile bare
-u / --unstable bare
-f / --justfile takes a value
-d / --working-directory takes a value
--justfile=… / --working-directory=… inline value

Those flags are collected into _just_dump_args and passed to just --dump, so the group list is read from the same justfile the recipe would actually run from. Anything else — a flag's value under the cursor, a recipe already typed, an unrecognized flag — returns 1 and delegates to the native completer exactly as before.

Verification

Exercised the real function with a stubbed _describe across eight cursor positions (from the chezmoi repo, which has both a local and a global justfile):

Input Result
just <TAB> local groups: chezmoi, claude, info, maintain, nvim, plugins, setup, test
just -g <TAB> global groups: claude, git, plugins
just --global-justfile <TAB> global groups ✅
just -f ~/.config/just/justfile <TAB> global groups ✅
just -f <TAB> → clap (completing the path argument) ✅
just -g -<TAB> → clap (completing a flag) ✅
just -g plugins-list <TAB> → clap (recipe arguments) ✅
just plugins-list <TAB> → clap (recipe arguments) ✅

Also confirmed the file autoloads clean under zsh -f + compinit, and pre-commit run --files dot_zfunc/_just passes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FT48Qpo3D1W34kP9LNx4Qb

The custom `_just` completer only took the grouped path when the recipe
name sat in word 2, so `just -g <TAB>` fell through to just's clap dynamic
completer — which returns the global recipes flattened into a single
`values` group alongside all 68 CLI flags. fzf-tab rendered that as one
unusable flat list with no `[group(...)]` headers and no `,`/`.` switching.

Add `_just_recipe_position`, which walks the words before the cursor and
accepts a leading run of justfile-selecting flags (`-g`/`--global-justfile`,
`-f`/`--justfile`, `-d`/`--working-directory`, `-u`/`--unstable`, and their
`--flag=value` forms). Those flags are collected into `_just_dump_args` and
passed to `just --dump`, so the group list is read from the same justfile the
recipe would actually run from. Anything else — a flag's value under the
cursor, a recipe already typed, an unrecognized flag — still returns 1 and
delegates to the native completer.

Verified against a stubbed `_describe` across eight cursor positions:
`just <TAB>` keeps the local groups, `just -g <TAB>` / `just -f <path> <TAB>`
now yield the global justfile's claude/git/plugins groups, and `just -f <TAB>`,
`just -g -<TAB>`, `just -g plugins-list <TAB>` all still fall through to clap.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FT48Qpo3D1W34kP9LNx4Qb
@laurigates
laurigates merged commit 9fcf6e3 into main Jul 29, 2026
9 of 10 checks passed
@laurigates
laurigates deleted the fix/just-global-flag-completion branch July 29, 2026 10:42
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Claude analyzed the CI failures but determined no code changes are needed.

Failed workflow: https://github.com/laurigates/dotfiles/actions/runs/30444116270

This may indicate:

  • Flaky tests
  • Infrastructure issues
  • Transient failures
  • Configuration problems outside the codebase

Please review the failure logs manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant