7c50867d2e71c911b5684c1613e1c1524f099c02
- Author
- Bobby DeSimone <bobbydesimone@gmail.com>
- Committer
- Bobby DeSimone <bobbydesimone@gmail.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/plugins/golang/golang.plugin.zsh b/plugins/golang/golang.plugin.zsh
2new file mode 100644
3index 0000000000000000000000000000000000000000..e60c4afe48e0b44cac537422229f8f32943a0349
4--- /dev/null
5+++ b/plugins/golang/golang.plugin.zsh
6@@ -0,0 +1,150 @@
7+# From : http://golang.org/misc/zsh/go?m=text
8+# gc
9+prefixes=(5 6 8)
10+for p in $prefixes; do
11+ compctl -g "*.${p}" ${p}l
12+ compctl -g "*.go" ${p}g
13+done
14+
15+# standard go tools
16+compctl -g "*.go" gofmt
17+
18+# gccgo
19+compctl -g "*.go" gccgo
20+
21+# go tool
22+__go_tool_complete() {
23+ typeset -a commands build_flags
24+ commands+=(
25+ 'build[compile packages and dependencies]'
26+ 'clean[remove object files]'
27+ 'doc[run godoc on package sources]'
28+ 'fix[run go tool fix on packages]'
29+ 'fmt[run gofmt on package sources]'
30+ 'get[download and install packages and dependencies]'
31+ 'help[display help]'
32+ 'install[compile and install packages and dependencies]'
33+ 'list[list packages]'
34+ 'run[compile and run Go program]'
35+ 'test[test packages]'
36+ 'tool[run specified go tool]'
37+ 'version[print Go version]'
38+ 'vet[run go tool vet on packages]'
39+ )
40+ if (( CURRENT == 2 )); then
41+ # explain go commands
42+ _values 'go tool commands' ${commands[@]}
43+ return
44+ fi
45+ build_flags=(
46+ '-a[force reinstallation of packages that are already up-to-date]'
47+ '-n[print the commands but do not run them]'
48+ "-p[number of parallel builds]:number"
49+ '-x[print the commands]'
50+ "-work[print temporary directory name and keep it]"
51+ "-gcflags[flags for 5g/6g/8g]:flags"
52+ "-ldflags[flags for 5l/6l/8l]:flags"
53+ "-gccgoflags[flags for gccgo]:flags"
54+ )
55+ __go_list() {
56+ local expl importpaths
57+ declare -a importpaths
58+ importpaths=($(go list ${words[$CURRENT]}... 2>/dev/null))
59+ _wanted importpaths expl 'import paths' compadd "$@" - "${importpaths[@]}"
60+ }
61+ case ${words[2]} in
62+ clean|doc)
63+ _arguments -s -w : '*:importpaths:__go_list'
64+ ;;
65+ fix|fmt|list|vet)
66+ _alternative ':importpaths:__go_list' ':files:_path_files -g "*.go"'
67+ ;;
68+ install)
69+ _arguments -s -w : ${build_flags[@]} \
70+ "-v[show package names]" \
71+ '*:importpaths:__go_list'
72+ ;;
73+ get)
74+ _arguments -s -w : \
75+ ${build_flags[@]}
76+ ;;
77+ build)
78+ _arguments -s -w : \
79+ ${build_flags[@]} \
80+ "-v[show package names]" \
81+ "-o[output file]:file:_files" \
82+ "*:args:{ _alternative ':importpaths:__go_list' ':files:_path_files -g \"*.go\"' }"
83+ ;;
84+ test)
85+ _arguments -s -w : \
86+ ${build_flags[@]} \
87+ "-c[do not run, compile the test binary]" \
88+ "-i[do not run, install dependencies]" \
89+ "-v[print test output]" \
90+ "-x[print the commands]" \
91+ "-short[use short mode]" \
92+ "-parallel[number of parallel tests]:number" \
93+ "-cpu[values of GOMAXPROCS to use]:number list" \
94+ "-run[run tests and examples matching regexp]:regexp" \
95+ "-bench[run benchmarks matching regexp]:regexp" \
96+ "-benchtime[run each benchmark during n seconds]:duration" \
97+ "-timeout[kill test after that duration]:duration" \
98+ "-cpuprofile[write CPU profile to file]:file:_files" \
99+ "-memprofile[write heap profile to file]:file:_files" \
100+ "-memprofilerate[set heap profiling rate]:number" \
101+ "*:args:{ _alternative ':importpaths:__go_list' ':files:_path_files -g \"*.go\"' }"
102+ ;;
103+ help)
104+ _values "${commands[@]}" \
105+ 'gopath[GOPATH environment variable]' \