fix(zsh): group just -g recipe completion like bare just - #347
Merged
Conversation
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
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:
Please review the failure logs manually. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:So
just -g <TAB>landed at word 3 and fell through tojust's clap dynamic completer, which returns the global recipes flattened into onevaluesgroup 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:-g/--global-justfile-u/--unstable-f/--justfile-d/--working-directory--justfile=…/--working-directory=…Those flags are collected into
_just_dump_argsand passed tojust --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
_describeacross eight cursor positions (from the chezmoi repo, which has both a local and a global justfile):just <TAB>just -g <TAB>just --global-justfile <TAB>just -f ~/.config/just/justfile <TAB>just -f <TAB>just -g -<TAB>just -g plugins-list <TAB>just plugins-list <TAB>Also confirmed the file autoloads clean under
zsh -f+compinit, andpre-commit run --files dot_zfunc/_justpasses.🤖 Generated with Claude Code
https://claude.ai/code/session_01FT48Qpo3D1W34kP9LNx4Qb