Include XDG_DATA_DIRS/share/zsh/site-functions in FPATH by default?

Jade Lovelace <[email protected]>
Newsgroups gmane.comp.shells.zsh.devel,gmane.comp.shells.zsh.user
Message-ID <CAC_G=Dabvii56rFAsTJZ3gjj9qakV_fojGwf26wO3mGVwg3owQ@mail.gmail.com>
It's conventional in some distro packaging such as on NixOS to put the
completions in a directory in $XDG_DATA_DIRS/share/zsh/site-functions.
Currently NixOS injects a zshenv which contains:

if [[ -z "${__ETC_ZSHENV_SOURCED:-}" ]]; then
    # Tell zsh how to find installed completions.
    for p in ''${(z)NIX_PROFILES}; do
        fpath=($p/share/zsh/site-functions
$p/share/zsh/$ZSH_VERSION/functions $p/share/zsh/vendor-completions
$fpath)
    done
fi

Nix will put each package's share directory in XDG_DATA_DIRS when
creating ephemeral shell environments as well.

This is superfluous in bash which uses XDG_DATA_DIRS by default:
https://github.com/scop/bash-completion/blob/51b009f6a653c66454816e9bc869c40f61329764/README.md?plain=1#L362-L372
and https://github.com/scop/bash-completion/blob/51b009f6a653c66454816e9bc869c40f61329764/bash_completion#L3306-L3309.

I am wondering if zsh has considered doing this by default as well, as
it makes zsh integrate cleanly with other tooling that uses
XDG_DATA_DIRS without specially needing to consider adding zsh
specific code to handle FPATH.

Regards,
Jade
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.