Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix zsh global install #466

Merged
merged 3 commits into from
Dec 9, 2023

Conversation

evanunderscore
Copy link
Collaborator

This fixes zsh global completion breakage introduced in #463, and updates the test to use a similar method as activate-global-python-argcomplete for zsh.

The zsh global completion script was previously mixing paradigms; it seems that you are supposed to use a file with a #compdef comment which is autoloaded, or manually call compdef yourself. I've updated this to only use the #compdef comment, but it does feel like everything would be simpler if we went the other way and sourced the file directly as we do with bash. The only catch with that is we would probably have to append this to ~/.zshrc instead of ~/.zshenv since we need compdef to be available, and it seems undesirable to autoload compdef on the user's behalf.

@codecov-commenter
Copy link

codecov-commenter commented Dec 8, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (d696194) 81.12% compared to head (6095cde) 81.12%.
Report is 1 commits behind head on develop.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #466   +/-   ##
========================================
  Coverage    81.12%   81.12%           
========================================
  Files           10       10           
  Lines          784      784           
========================================
  Hits           636      636           
  Misses         148      148           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kislyuk
Copy link
Owner

kislyuk commented Dec 9, 2023

@evanunderscore as far as I know, we can't source the file directly (at least not without making our installation process a lot less general). Zsh has no default facility to source completion scripts at startup - instead it scans the first lines of these files for compdef declarations. The actual scripts are sourced on demand according to those declarations.

By the way, we will be facing something similar with bash soon. Bash completion v1 (which is what we use for global completion installation) sources entire scripts, but it's deprecated. Bash completion v2 uses a similar lazy-load pattern that does not allow registering a global completion fallback (complete -D, which is what we use).

We could always use the alternative strategy of telling the user to source the file directly in their rc script, but that's not a systemwide installation method and it's brittle in other ways.

Testing this branch now.

@kislyuk
Copy link
Owner

kislyuk commented Dec 9, 2023

Testing looks good, I agree this approach seems to be the best.

@kislyuk kislyuk merged commit 7931f75 into kislyuk:develop Dec 9, 2023
24 checks passed
@kislyuk
Copy link
Owner

kislyuk commented Dec 10, 2023

Released in v3.2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants