diff --git a/.chezmoiexternal.yaml b/.chezmoiexternal.yaml index 476bc71..13932e6 100644 --- a/.chezmoiexternal.yaml +++ b/.chezmoiexternal.yaml @@ -23,3 +23,8 @@ type: git-repo url: https://github.com/zsh-users/zsh-syntax-highlighting.git clone.args: --branch 0.7.1 +{{- if .development.conda }} +.local/share/zsh/completion/zsh-conda-completion: + type: git-repo + url: https://github.com/conda-incubator/conda-zsh-completion.git +{{- end }} diff --git a/dot_config/conda/condarc.tmpl b/dot_config/conda/condarc.tmpl index cf8d3d7..d163692 100644 --- a/dot_config/conda/condarc.tmpl +++ b/dot_config/conda/condarc.tmpl @@ -4,8 +4,9 @@ channels: channel_priority: strict -envs_dirs: - - {{ .paths.data }}/conda/envs +# define this in zshrc so the completion engine can find my local envs +#envs_dirs: +# - {{ .paths.data }}/conda/envs pkgs_dirs: - {{ .paths.data }}/conda/pkgs diff --git a/dot_config/zsh/dot_zshrc.tmpl b/dot_config/zsh/dot_zshrc.tmpl index 6d6e3b4..5e159c2 100644 --- a/dot_config/zsh/dot_zshrc.tmpl +++ b/dot_config/zsh/dot_zshrc.tmpl @@ -42,6 +42,11 @@ alias_if_sudo () { # autocompletion ## -------------------------------------------------- +{{ if .development.conda -}} +# add conda completions to path if desired +fpath+="$XDG_DATA_HOME/zsh/completion/zsh-conda-completion" +{{- end }} + # load stuff (order matters) zmodload zsh/complist autoload -Uz compinit && compinit -i @@ -64,6 +69,12 @@ zstyle ':completion:*:*:*:*:descriptions' format '%F{green}-- %d --%f' zstyle ':completion:*:messages' format ' %F{purple} -- %d --%f' zstyle ':completion:*:warnings' format ' %F{red}-- no matches found --%f' +{{ if .development.conda -}} +# show group headers for conda completion +zstyle ":conda_zsh_completion:*" use-groups true +zstyle ':completion::complete:*' use-cache 1 +{{- end }} + # use sane grouping zstyle ':completion:*' group-name '' @@ -469,5 +480,8 @@ zsh-conda () { alias cda="conda activate" alias cde="conda env" alias cdl="conda list" + + # this is here and not in condarc so comp can find local envs + export CONDA_ENVS_DIRS=$XDG_DATA_HOME/conda/envs } {{- end }}