From 547a6ce260362b06e86a9c366dc29984c0954124 Mon Sep 17 00:00:00 2001 From: Jeremy Jones Date: Sat, 23 Jun 2018 23:52:53 -0500 Subject: fix path completion issue with go run subcommand (#6929) --- plugins/golang/golang.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/golang') diff --git a/plugins/golang/golang.plugin.zsh b/plugins/golang/golang.plugin.zsh index d9d450690..d5c78ce6c 100644 --- a/plugins/golang/golang.plugin.zsh +++ b/plugins/golang/golang.plugin.zsh @@ -135,7 +135,7 @@ __go_tool_complete() { run) _arguments -s -w : \ ${build_flags[@]} \ - '*:file:_path_files -g "*.go"' + '*:file:_files -g "*.go"' ;; tool) if (( CURRENT == 3 )); then -- cgit v1.2.3-70-g09d2 From 8961a3794cc2f5bc31b592367e82aa1766f24bbd Mon Sep 17 00:00:00 2001 From: Joseph Richey Date: Tue, 7 Aug 2018 13:54:45 -0700 Subject: plugins/go: Simplify/fix recursive golang format (#7027) Per the [`go` command specification](https://golang.org/cmd/go/#hdr-Package_lists), the `...` wildcard matches the empty string. This makes commands like `go . ./...` unnecessary: they should use `go ./...`. This also fixes a bug with the `gofa` shortcut, where it would emit an error if called from a directory containing no go source files (but having subdirectories that _did_ contain go files). --- plugins/golang/golang.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/golang') diff --git a/plugins/golang/golang.plugin.zsh b/plugins/golang/golang.plugin.zsh index d5c78ce6c..64c80e864 100644 --- a/plugins/golang/golang.plugin.zsh +++ b/plugins/golang/golang.plugin.zsh @@ -184,7 +184,7 @@ alias gob='go build' alias goc='go clean' alias god='go doc' alias gof='go fmt' -alias gofa='go fmt . ./...' +alias gofa='go fmt ./...' alias gog='go get' alias goi='go install' alias gol='go list' -- cgit v1.2.3-70-g09d2 From 8ec0937653f30277361621191e8cee01b7fc089d Mon Sep 17 00:00:00 2001 From: Matthew Murphy Date: Wed, 29 Aug 2018 14:55:23 -0400 Subject: Update golang.plugin.zsh (#6750) add alias to cd to $GOPATH, $GOPATH/src, $GOPATH/bin --- plugins/golang/golang.plugin.zsh | 3 +++ 1 file changed, 3 insertions(+) (limited to 'plugins/golang') diff --git a/plugins/golang/golang.plugin.zsh b/plugins/golang/golang.plugin.zsh index 64c80e864..919c98629 100644 --- a/plugins/golang/golang.plugin.zsh +++ b/plugins/golang/golang.plugin.zsh @@ -188,6 +188,9 @@ alias gofa='go fmt ./...' alias gog='go get' alias goi='go install' alias gol='go list' +alias gop='cd $GOPATH' +alias gopb='cd $GOPATH/bin' +alias gops='cd $GOPATH/src' alias gor='go run' alias got='go test' alias gov='go vet' -- cgit v1.2.3-70-g09d2 From dfe7d6eca119ac58be04a2ef1bf142c3e78b6c1a Mon Sep 17 00:00:00 2001 From: Bjorn Stange Date: Wed, 3 Oct 2018 12:13:48 -0400 Subject: golang: add README (#7207) --- plugins/golang/README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 plugins/golang/README.md (limited to 'plugins/golang') diff --git a/plugins/golang/README.md b/plugins/golang/README.md new file mode 100644 index 000000000..72845b2a1 --- /dev/null +++ b/plugins/golang/README.md @@ -0,0 +1,29 @@ +# Golang plugin + +This plugin adds completion for the [Go Programming Language](https://golang.org/), +as well as some aliases for common Golang commands. + +To use it, add `golang` to the plugins array in your zshrc file: + +```zsh +plugins=(... golang) +``` + +## Aliases + +| Alias | Command | Description | +| ------- | ----------------------- | ------------------------------------------------------------- | +| gob | `go build` | Build your code | +| goc | `go clean` | Removes object files from package source directories | +| god | `go doc` | Prints documentation comments | +| gof | `go fmt` | Gofmt formats (aligns and indents) Go programs. | +| gofa | `go fmt ./...` | Run go fmt for all packages in current directory, recursively | +| gog | `go get` | Downloads packages and then installs them to $GOPATH | +| goi | `go install` | Compiles and installs packages to $GOPATH | +| gol | `go list` | Lists Go packages | +| gop | `cd $GOPATH` | Takes you to $GOPATH | +| gopb | `cd $GOPATH/bin` | Takes you to $GOPATH/bin | +| gops | `cd $GOPATH/src` | Takes you to $GOPATH/src | +| gor | `go run` | Compiles and runs your code | +| got | `go test` | Runs tests | +| gov | `go vet` | Vet examines Go source code and reports suspicious constructs | -- cgit v1.2.3-70-g09d2 From e8aba1bf5912f89f408eaebd1bc74c25ba32a62c Mon Sep 17 00:00:00 2001 From: Ricardo Seriani Date: Fri, 16 Nov 2018 18:53:29 -0300 Subject: golang: support "go help environment" in autocompletion (#7404) Signed-off-by: Ricardo Seriani --- plugins/golang/golang.plugin.zsh | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins/golang') diff --git a/plugins/golang/golang.plugin.zsh b/plugins/golang/golang.plugin.zsh index 919c98629..8284ab83c 100644 --- a/plugins/golang/golang.plugin.zsh +++ b/plugins/golang/golang.plugin.zsh @@ -126,6 +126,7 @@ __go_tool_complete() { ;; help) _values "${commands[@]}" \ + 'environment[show Go environment variables available]' \ 'gopath[GOPATH environment variable]' \ 'packages[description of package lists]' \ 'remote[remote import path syntax]' \ -- cgit v1.2.3-70-g09d2 From ae7d0bcdb9d22a2de4150f2f00a5c0a26b857c48 Mon Sep 17 00:00:00 2001 From: Andrey Skurlatov Date: Tue, 26 Mar 2019 00:36:46 +0300 Subject: golang: mod and list commands completion (#7665) Also, add `gom` alias to `go mod`. --- plugins/golang/golang.plugin.zsh | 79 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 78 insertions(+), 1 deletion(-) (limited to 'plugins/golang') diff --git a/plugins/golang/golang.plugin.zsh b/plugins/golang/golang.plugin.zsh index 8284ab83c..47b10988e 100644 --- a/plugins/golang/golang.plugin.zsh +++ b/plugins/golang/golang.plugin.zsh @@ -28,6 +28,7 @@ __go_tool_complete() { 'help[display help]' 'install[compile and install packages and dependencies]' 'list[list packages]' + 'mod[modules maintenance]' 'run[compile and run Go program]' 'test[test packages]' 'tool[run specified go tool]' @@ -83,7 +84,7 @@ __go_tool_complete() { "-x[print remove commands as it executes them]" \ "*:importpaths:__go_packages" ;; - fix|fmt|list|vet) + fix|fmt|vet) _alternative ':importpaths:__go_packages' ':files:_path_files -g "*.go"' ;; install) @@ -124,6 +125,81 @@ __go_tool_complete() { "-memprofilerate[set heap profiling rate]:number" \ "*:args:{ _alternative ':importpaths:__go_packages' ':files:_path_files -g \"*.go\"' }" ;; + list) + _arguments -s -w : \ + "-f[alternative format for the list]:format" \ + "-json[print data in json format]" \ + "-compiled[set CompiledGoFiles to the Go source files presented to the compiler]" \ + "-deps[iterate over not just the named packages but also all their dependencies]" \ + "-e[change the handling of erroneous packages]" \ + "-export[set the Export field to the name of a file containing up-to-date export information for the given package]" \ + "-find[identify the named packages but not resolve their dependencies]" \ + "-test[report not only the named packages but also their test binaries]" \ + "-m[list modules instead of packages]" \ + "-u[adds information about available upgrades]" \ + "-versions[set the Module's Versions field to a list of all known versions of that module]:number" \ + "*:importpaths:__go_packages" + ;; + mod) + typeset -a mod_commands + mod_commands+=( + 'download[download modules to local cache]' + 'edit[edit go.mod from tools or scripts]' + 'graph[print module requirement graph]' + 'init[initialize new module in current directory]' + 'tidy[add missing and remove unused modules]' + 'vendor[make vendored copy of dependencies]' + 'verify[verify dependencies have expected content]' + 'why[explain why packages or modules are needed]' + ) + if (( CURRENT == 3 )); then + _values 'go mod commands' ${mod_commands[@]} "help[display help]" + return + fi + case ${words[3]} in + help) + _values 'go mod commands' ${mod_commands[@]} + ;; + download) + _arguments -s -w : \ + "-json[print a sequence of JSON objects standard output]" \ + "*:flags" + ;; + edit) + _arguments -s -w : \ + "-fmt[reformat the go.mod file]" \ + "-module[change the module's path]" \ + "-replace[=old{@v}=new{@v} add a replacement of the given module path and version pair]:name" \ + "-dropreplace[=old{@v}=new{@v} drop a replacement of the given module path and version pair]:name" \ + "-go[={version} set the expected Go language version]:number" \ + "-print[print the final go.mod in its text format]" \ + "-json[print the final go.mod file in JSON format]" \ + "*:flags" + ;; + graph) + ;; + init) + ;; + tidy) + _arguments -s -w : \ + "-v[print information about removed modules]" \ + "*:flags" + ;; + vendor) + _arguments -s -w : \ + "-v[print the names of vendored]" \ + "*:flags" + ;; + verify) + ;; + why) + _arguments -s -w : \ + "-m[treats the arguments as a list of modules and finds a path to any package in each of the modules]" \ + "-vendor[exclude tests of dependencies]" \ + "*:importpaths:__go_packages" + ;; + esac + ;; help) _values "${commands[@]}" \ 'environment[show Go environment variables available]' \ @@ -189,6 +265,7 @@ alias gofa='go fmt ./...' alias gog='go get' alias goi='go install' alias gol='go list' +alias gom='go mod' alias gop='cd $GOPATH' alias gopb='cd $GOPATH/bin' alias gops='cd $GOPATH/src' -- cgit v1.2.3-70-g09d2