diff options
| author | nicoulaj <julien.nicoulaud@gmail.com> | 2019-09-20 21:24:51 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-09-20 21:24:51 +0200 |
| commit | ca24e66278072058b49f0d6bb8b4f13de9f93c31 (patch) | |
| tree | cceb008474889e63474e3ee653627f1bd4f8893f | |
| parent | #610: add compdef for concourse 5.2.0 (https://concourse-ci.org) (diff) | |
| parent | [golang] unify package completion for build and run (diff) | |
| download | zsh-completions-ca24e66278072058b49f0d6bb8b4f13de9f93c31.tar zsh-completions-ca24e66278072058b49f0d6bb8b4f13de9f93c31.tar.gz zsh-completions-ca24e66278072058b49f0d6bb8b4f13de9f93c31.tar.bz2 zsh-completions-ca24e66278072058b49f0d6bb8b4f13de9f93c31.tar.lz zsh-completions-ca24e66278072058b49f0d6bb8b4f13de9f93c31.tar.xz zsh-completions-ca24e66278072058b49f0d6bb8b4f13de9f93c31.tar.zst zsh-completions-ca24e66278072058b49f0d6bb8b4f13de9f93c31.zip | |
Merge pull request #642 from pseyfert/go-relative-paths
[golang] unify package completion for build and run
| -rw-r--r-- | src/_golang | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/_golang b/src/_golang index 5515529..8d84caa 100644 --- a/src/_golang +++ b/src/_golang @@ -117,8 +117,18 @@ case $state in gopaths=("${(s/:/)$(go env GOPATH)}") gopaths+=("$(go env GOROOT)") for p in $gopaths; do - _path_files -W "$p/src" -/ + _path_files $@ -W "$p/src" -/ done + # no special treatment for + # - relative paths starting with .. + # - absolute path starting with / + # - variables, substitutions, subshells + if [[ $words[$CURRENT] = ..* || $words[$CURRENT] = \$* || $words[$CURRENT] = /* ]]; then + _path_files $@ -/ -g '*.go' + else + # go build accepts paths relative to the cwd but they must start with './', so prefix them + _path_files $@ -P './' -/ -g '*.go' + fi } case $words[1] in @@ -266,7 +276,7 @@ case $state in _arguments \ ${build_flags[@]} \ '-exec[invoke the binary using xprog]:xporg' \ - '*:file:_files -g "*.go(-.)"' + '*:importpaths:__go_packages' ;; test) |
