From 01838f008336325e8cfa4ddab0e8543730c869b8 Mon Sep 17 00:00:00 2001 From: Matt Hamilton Date: Thu, 17 Dec 2015 02:12:02 -0500 Subject: [PATCH] add compdef for pacman aliases The recommended order for the module loading has been changed. The last module to be loaded should be 'completion'. This ensures all completions set by other modules are dumped and included in the completion. Because of this, any compdefs like this one (making the pacman aliases use pacman completion) must be set in the compdefs.zsh file, and loaded with the completion module. This means the compdefs must be wrapped with conditional statements to ensure such aliases/functions have been set by previous modules. I may abstract this conditional to a function in the future to make this an easier process. --- modules/completion/compdefs.zsh | 14 ++++++++++++++ modules/completion/init.zsh | 4 ++++ modules/pacman/alias.zsh | 1 - 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 modules/completion/compdefs.zsh diff --git a/modules/completion/compdefs.zsh b/modules/completion/compdefs.zsh new file mode 100644 index 0000000..465f8e3 --- /dev/null +++ b/modules/completion/compdefs.zsh @@ -0,0 +1,14 @@ +# +# 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 fc5e420..5197a18 100644 --- a/modules/completion/init.zsh +++ b/modules/completion/init.zsh @@ -17,6 +17,10 @@ fpath=(${0:h}/external/src ${fpath}) # load and initialize the completion system autoload -Uz compinit && compinit -C -d ${ZDOTDIR:-$HOME}/.zcompdump + +# set any compdefs +source ${0:h}/compdefs.zsh + { # zcomple the .zcompdump in the background local zcompdump=${ZDOTDIR:-$HOME}/.zcompdump diff --git a/modules/pacman/alias.zsh b/modules/pacman/alias.zsh index 957d695..0c67b35 100644 --- a/modules/pacman/alias.zsh +++ b/modules/pacman/alias.zsh @@ -9,7 +9,6 @@ # General # -alias pacman=${zpacman_frontend} alias pac=${zpacman_frontend} #