zsh-capture-completion
zsh-capture-completion copied to clipboard
Allow to capture completions and functions defined in the .zshrc
I've tested this with the powerlevel10k prompt which needed some special handling. Depending on the plugins loaded in the zshrc this might also have some unwanted side effects.
phewww. zsh env files do really arbitrary stuff, we can't hope to reliably deal with that in the general case. the "for powerlevel10k we'll need to disable the prompt twice" confirms this, it's extremely likely that there will be quirks for other configurations as well. I don't think this is a good change in default behavior.
As an alternative, how about a parameter that allows sourcing a file? That way the user could explicitly load a file, preferably one with function definitions but no other side effects, and get completions for them that way.
Yes, dealing with the zsh env something will probably go wrong.
But using zpty z zsh -f -i and zpty -w z source ~/.zshrc wouldn't work for me not even with my additions (because of said prompt).
And I'm sure this is something someone would try.
Another issue at least I'd come across is loading some kind of completions (zsh-users/zsh-completions for example) in the .zshrc where I also load powerlevel10k.
As for the second disabling of the PROMPT - this is actually incorrect. It just needs to be disabled before the init script. So the init script could drop the first line.
Since capture.zsh ~/.zshrc wouldn't work what about let g:zshCompletionLoadFullEnv = v:true which would then enable the new behavior?