diff options
| author | Paul Seyfert <pseyfert.mathphys@gmail.com> | 2019-07-18 23:07:32 +0200 |
|---|---|---|
| committer | Paul Seyfert <pseyfert.mathphys@gmail.com> | 2019-07-18 23:07:32 +0200 |
| commit | e73235f0dfb9e483d019ede7abd019f29434ab89 (patch) | |
| tree | cceb008474889e63474e3ee653627f1bd4f8893f /src/_golang | |
| parent | #610: add compdef for concourse 5.2.0 (https://concourse-ci.org) (diff) | |
| download | zsh-completions-e73235f0dfb9e483d019ede7abd019f29434ab89.tar zsh-completions-e73235f0dfb9e483d019ede7abd019f29434ab89.tar.gz zsh-completions-e73235f0dfb9e483d019ede7abd019f29434ab89.tar.bz2 zsh-completions-e73235f0dfb9e483d019ede7abd019f29434ab89.tar.lz zsh-completions-e73235f0dfb9e483d019ede7abd019f29434ab89.tar.xz zsh-completions-e73235f0dfb9e483d019ede7abd019f29434ab89.tar.zst zsh-completions-e73235f0dfb9e483d019ede7abd019f29434ab89.zip | |
[golang] unify package completion for build and run
* let both `go build` and `go run` suggest local files and dirs with
`go build ./something`
* let both suggest package identifiers
`go build github.com/username/reponame`
* automatically prefix relative paths with './'
`go build file<TAB>` → `go build ./file.go`
Diffstat (limited to 'src/_golang')
| -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) |
