🐛 Fix zsh autocompletion installation#237
Conversation
This is an opinionated change that can affect users existing completion configuration.
compinit must be run after fpath is updated, to load new completions. Don't add extraneous newlines at the end of zshrc.
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
|
I was having problems with autocompletion on zsh (oh-my-zsh), and these changes fixed it. |
svlandeg
left a comment
There was a problem hiding this comment.
I can confirm that the zsh completion wasn't working as expected. The second "compinit" line was never written to .zshrc due to the if line not in completion_init_lines check, as the string "compinit" was already part of the first line.
Additionally, as pointed out in the description of the PR and in previous discussions, the order of commands was wrong.
On master, my .zshrc would look like this:
autoload -Uz compinit
zstyle ':completion:*' menu select
fpath+=C:\Users\Sofie\.zfunc
and autocompletion wouldn't work.
With this PR, my .zshrc would look like this:
autoload -Uz compinit
fpath+=~/.zfunc
compinit
and autocompletion works 🎉
Thanks for this contribution @alexjurkiewicz and apologies for the long delay in reviewing this!
zsh autocompletionzsh autocompletion installation
|
Great, thank you @alexjurkiewicz! 🚀 And thanks @svlandeg for the review! 🙇 I've been studying today a bit about all this (I always have to re-study all the completion stuff when working on this 😅 ), these were good resources:
I realized that all the Zsh completion installation could be a single line, which makes it easier to test for in the About the styling, as up to now the completion has installed the style configs, I won't remove this, at least not in this PR that is fixing a bug, maybe that could be considered a breaking change as it's a change in behavior, not sure. 🤔 Still, I updated it to checking if there's a My doubt about removing the For now, let's leave this PR at fixing completion installation for Zsh. 😎 🚀 Thank you for your contribution! 🍰 This will be available in Typer |
I ran into issues installing completiong from a typer-enhanced program. Here are two fixes:
.zshrc.compinitmust be run afterfpathis adjusted, for new completions to be loaded.I tested this logic with my current zsh (using oh-my-zsh) and with a bare zshrc, and it works in both cases.