From 61cc8182f9cd25bbf9d24f5f87881e1766065395 Mon Sep 17 00:00:00 2001 From: Eric Nielsen Date: Wed, 26 Sep 2018 15:29:54 -0500 Subject: [PATCH] [pacman] Remove dependency from completion module The completion module has specific code for the pacman module, and we want to make modules independent from each other. Plus, as far as I checked, most of the pacman wrappers/frontends are already packaged with zsh completion out of the box. I'm not an archlinux user, but I checked the repos of the ones in https://wiki.archlinux.org/index.php/AUR_helpers#Pacman_wrappers and these contain zsh completion scripts: * aura: https://github.com/aurapm/aura/blob/master/aura/doc/completions/_aura * pacaur: https://github.com/rmarquis/pacaur/blob/master/zsh.completion * pakku: https://github.com/kitsunyan/pakku/blob/master/completion/zsh.patch * pikaur: https://github.com/actionless/pikaur/blob/master/packaging/usr/share/zsh/site-functions/_pikaur * trizen: https://github.com/trizen/trizen/blob/master/zsh.completion * yay: https://github.com/Jguer/yay/blob/master/completions/zsh I didn't find zsh completions for the ones listed below, so I added a compdef function for them inside the pacman module itself: * aurman * packer-aur * wrapaur * yaourt --- modules/completion/compdefs.zsh | 14 -------------- modules/completion/init.zsh | 3 --- modules/pacman/functions/_pacman_frontend | 3 +++ 3 files changed, 3 insertions(+), 17 deletions(-) delete mode 100644 modules/completion/compdefs.zsh create mode 100644 modules/pacman/functions/_pacman_frontend diff --git a/modules/completion/compdefs.zsh b/modules/completion/compdefs.zsh deleted file mode 100644 index 465f8e3..0000000 --- a/modules/completion/compdefs.zsh +++ /dev/null @@ -1,14 +0,0 @@ -# -# Alias compdefs -# - -# Any aliased commands will not function with completion without compdefs. -# Because completion is the LAST module to be loaded (so we make sure to catch all completions) -# we must assign the compdefs here, as opposed to within the modules themselves. - -# Unfortunately, I'm not aware of a worthwhile way to ensure that these will be included in .zcompdump - -# zpacman_frontend -> pacman -if (( ${+zpacman_frontend} )); then - compdef ${zpacman_frontend}='pacman' -fi diff --git a/modules/completion/init.zsh b/modules/completion/init.zsh index 12b2023..161ea98 100644 --- a/modules/completion/init.zsh +++ b/modules/completion/init.zsh @@ -18,9 +18,6 @@ fpath=(${0:h}/external/src ${fpath}) # load and initialize the completion system autoload -Uz compinit && compinit -C -d "${ZDOTDIR:-${HOME}}/${zcompdump_file:-.zcompdump}" -# set any compdefs -source ${0:h}/compdefs.zsh - # # zsh options diff --git a/modules/pacman/functions/_pacman_frontend b/modules/pacman/functions/_pacman_frontend new file mode 100644 index 0000000..2f2bf71 --- /dev/null +++ b/modules/pacman/functions/_pacman_frontend @@ -0,0 +1,3 @@ +#compdef aurman packer wrapaur yaourt + +service=pacman; _pacman