-
-
Notifications
You must be signed in to change notification settings - Fork 25.7k
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
Completion initialization (compinit) logic should be overridable / customizable #9258
Comments
totally agree that this is necessary, with this implemented we can reduce startup times like this: |
One other option if this change is too drastic - the compinit call could be wrapped in a function in oh-my-zsh.sh, and only declare it if you haven't already done so somewhere prior to sourcing OMZ in your own .zshrc. The advantage of this method would be that it's much less impactful to the overall structure of this project and would only require a few lines to change. The disadvantage is that it introduces an additional customization method beyond simply making a file in your $ZSH_CUSTOM. I'm willing to submit an alternative PR for this if that's a more acceptable avenue, but I think it's imperative for this customization to be possible for those of us who love OMZ, but are performance conscious of our ZSH environment. |
I implemented the simpler change as described above. It's now in this PR: #9537 Essentially, the compint logic is now wrapped in an existence checking function wrapper: (( $+functions[run_compinit] )) ||
function run_compinit() {
...
... same compint logic as before
...
}
run_compinit If this PR gets merged, you could override the OMZ compinit logic by defining your own run_compint function in .zshrc before sourcing oh-my-zsh.sh. This should help people who are interested in better performing compinit logic than OMZ provides currently. |
Is your feature request related to a particular plugin or theme? If so, specify it.
N/A
Is your feature request related to a problem? Please describe.
oh-my-zsh uses its core include (oh-my-zsh.sh) to handle completion initialization. This does not allow users to effectively customize that logic without forking this project or other means. Also, due to the way lib/*.zsh files are loaded, compfix.zsh is sourced multiple times.
By moving compinit logic into the lib folder, advanced users can then use $ZSH_CUSTOM to override compinit logic with their own. It also simplifies oh-my-zsh.sh into a simple core set of logic that is only responsible for handling OMZ environment settings and lib/plugin/theme sourcing and nothing else.
Describe the solution you'd like
Completion logic should be moved out of oh-my-zsh.sh and into the lib folder. To ensure it is loaded first, the file could be named with a numeric prefix or an underscore. The compinit file could also be combined with the compfix.zsh file.
Describe alternatives you've considered
Instead of a numeric prefix, the new lib/01-compinit.zsh file could just be called lib/compinit.zsh or placed someplace other than /lib, but would then need special logic in oh-my-zsh.sh. The way I'm proposing implementing this solution requires no additional logic in oh-my-zsh.sh, and in fact only moves code from that file.
Additional context
See PR #9257
Related Issues
N/A
The text was updated successfully, but these errors were encountered: