-
Notifications
You must be signed in to change notification settings - Fork 146
Feature: Add Native One-Time Installation for Local Plugins #750
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
base: main
Are you sure you want to change the base?
Conversation
|
Hi all, Thanks for taking a look at this. Based on further testing and refinement, I've pushed two new commits to this PR that significantly improve the initial proposal. Here’s a summary of the updates:
These changes are in two separate, logical commits. For a complete overview and for any new reviewers, I have updated the main pull request description to reflect the full scope of the feature. I'm pasting the final, consolidated version below for convenience. Feature: Add Native One-Time Installation for Local PluginsMotivation and ProblemCurrently, This prevents the automatic, declarative setup of features like completions, which normally run during the Solution and ImplementationThis pull request introduces a more integrated approach by treating a local plugin as a "pre-cloned" repository. This is achieved by patching
Usability ImprovementsThis patch also includes two significant usability enhancements: Automatic
|
…ocal, linked snippets
|
Hi all, I've pushed one more commit a66b381 to this PR to address a cross-platform compatibility bug I discovered during testing. ProblemWhen running However, macOS ships with a BSD version of SolutionThis new commit fixes the issue by adding a robust compatibility check. Before attempting to use the GNU
This ensures the |
Feature: Add Native One-Time Installation for Local Plugins
Motivation and Problem
Currently,
zinittreats local plugins (specified by an absolute path) differently from remote plugins. They lack a one-time "installation" phase, which means they are simply sourced "in-place" on every shell start.This prevents the automatic, declarative setup of features like completions, which normally run during the
atclonephase for remote plugins. As a result, users are forced to write complexatloadhooks with manual flag files to simulate this one-time setup, making the configuration for local plugins unnecessarily verbose and complex.For example, installing completions for a local plugin requires a workaround like this:
This is not intuitive and goes against
zinit's goal of clean, declarative syntax.Solution and Implementation
This pull request introduces a more integrated approach by treating a local plugin as a "pre-cloned" repository. It bridges the gap between remote and local plugin handling.
The implementation involves the following changes:
Detection in
.zinit-load()(zinit.zsh): The main load function is patched to detect when a new, unmanaged local plugin is being loaded. It then calls the main installation function, passing a speciallocaltype. A filter is included to prevent this logic from incorrectly triggering onzinit's own internal use of local paths (e.g., loading from$ZINIT[BIN_DIR]).Symlinking in
.zinit-setup-plugin-dir()(zinit-install.zsh): The main installation function is patched with a new branch to handle thelocaltype. Instead of cloning or downloading, it creates a symlink from the user's local plugin directory intozinit's managed$ZINIT[PLUGINS_DIR].Unified Post-Install Hooks: After the symlink is created, the function proceeds to run all the standard post-installation logic that is normally reserved for remote plugins. This includes the automatic scan for completions triggered by the
completionsice, runningmakehooks, etc.Improved Logging: The installation message has been updated to say
Installing local plugin...instead of the confusingDownloading %//...when this new logic is triggered.Benefits and User Experience
This change significantly improves the user experience for managing local plugins.
completionsice for local plugins, just as they would for remote ones.atloadworkarounds is eliminated.make,compile, etc.) will now also work as expected for local plugins on their first run.With this patch, the complex workaround from before becomes a simple, clean, and idiomatic
zinitcommand:A Note on Update Tracking
A key design consideration is update tracking. Since
zinitdoes not own the source of the local plugin (it only links to it), it cannot manage its updates viazinit update. The responsibility for keeping the local plugin's source directory up-to-date remains with the user. This is an expected and reasonable trade-off for the flexibility of managing plugins from one's own dotfiles or local projects.AI Assistance Disclaimer
This pull request, including the implementation of the patch and the descriptive text, was developed with the assistance of an AI model (Google's Gemini 2.5). The process was guided by a human developer who provided the specific logic, identified the target locations for surgical code changes, and directed the content and structure of this note. The final code and functionality have been thoroughly tested and validated by humans on macOS (Apple Silicon) and Linux (Ubuntu 22.04) to ensure correctness and stability.