How to fix zsh completions

I was trying to add some zsh completions and I couldn’t figure out why they weren’t working. I had added them into a folder that I was running autoload on, but I still couldn’t get it to work.

I found this stackoverflow post and it saved me.

Here is what my .zshrc looks like now.

The code

autoload -Uz compinit && compinit

# enable case insensitive tab completion
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
fpath=(/usr/local/share/zsh-completions $fpath)
source $DOTFILES/zsh-completions/_arduino_cli

NOTE: I set up environment variables for important paths hence the $DOTFILES line.

So what is this doing?

I think the gist of this is autoload compint (I was already doing this) and then source your completion files (I was not doing this).

I’ll probably later write a nice loop for this if I end up with more completions.