diff --git a/plugins/godoc/godoc.plugin.zsh b/plugins/godoc/godoc.plugin.zsh new file mode 100644 index 000000000..684141e68 --- /dev/null +++ b/plugins/godoc/godoc.plugin.zsh @@ -0,0 +1,50 @@ + +_godoc () { + + typeset -A opt_args + local context state line + local pkgdir usrpkgdir + + pkgdir="$GOROOT/src/pkg" + usrpkgdir="$GOPATH/src" + godoctmpl=$ZSH/plugins/godoc/templates + + _arguments -s -S \ + "-goroot+[Go root directory]::(/usr/lib/go)" \ + "-html[print HTML in command-line mode]" \ + "-http+[HTTP service address (e.g., :6060)]" \ + "-index[enable search index]" \ + "-index_files+[glob pattern specifying index files;if not empty, the index is read from these files in sorted order]" \ + "-index_throttle+[index throttle value; 0.0 = no time allocated, 1.0 = full throttle]::(0.75 0.0 1.0)" \ + "-maxresults+[maximum number of full text search results shown]::(10000)" \ + "-path+[additional package directories (colon-separated)]" \ + "-q[arguments are considered search queries]" \ + "-server+[webserver address for command line searches]" \ + "-src[print (exported) source in command-line mode]" \ + "-tabwidth+[tab width]::(4)" \ + "-templates+[directory containing alternate template files]" \ + "-testdir+[Go root subdirectory - for testing only (faster startups)]" \ + "-timestamps[show timestamps with directory listings]" \ + "-url+[print HTML for named URL]" \ + "-v[verbose mode]" \ + "-write_index[write index to a file; the file name must be specified with -index_files]" \ + "1:package:->pkgs" \ + "*:package contents:->pkg_content" + + case $state in + (pkgs) + _path_files -W "$pkgdir" -/ + _path_files -W "$usrpkgdir" -/ + return 0 + ;; + (pkg_content) + godoc_completions=$(godoc -templates "$godoctmpl" $words[-2] 2> /dev/null) + if [ $? -eq 0 ]; then + compadd "$@" $(echo "$godoc_completions") + fi + return 0 + ;; + esac +} + +compdef _godoc godoc \ No newline at end of file diff --git a/plugins/godoc/templates/package.txt b/plugins/godoc/templates/package.txt new file mode 100644 index 000000000..b806b3586 --- /dev/null +++ b/plugins/godoc/templates/package.txt @@ -0,0 +1,41 @@ +{{with .PDoc}}{{/* + +--------------------------------------- + +*/}}{{with .Consts}}{{range .}}{{range .Names}}{{.}} +{{end}}{{end}}{{end}}{{/* + +--------------------------------------- + +*/}}{{with .Vars}}{{range .}}{{range .Names}}{{.}} +{{end}}{{end}}{{end}}{{/* + +--------------------------------------- + +*/}}{{with .Funcs}}{{range .}}{{.Name}} +{{end}}{{end}}{{/* + +--------------------------------------- + +*/}}{{with .Types}}{{range .}}{{/* + +*/}}{{.Name}} +{{/* + +*/}}{{range .Methods}}{{.Name}} +{{end}}{{/* + +*/}}{{range .Funcs}}{{.Name}} +{{end}}{{/* + +*/}}{{range .Consts}}{{range .Names}}{{.}} +{{end}}{{end}}{{/* + +*/}}{{range .Vars}}{{range .Names}}{{.}} +{{end}}{{end}}{{/* + +*/}}{{end}}{{end}}{{/* + +--------------------------------------- + +*/}}{{end}} \ No newline at end of file