mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-30 02:44:42 +01:00
add godoc plugin
This commit is contained in:
parent
b34aee7f76
commit
20195379c3
2 changed files with 91 additions and 0 deletions
50
plugins/godoc/godoc.plugin.zsh
Normal file
50
plugins/godoc/godoc.plugin.zsh
Normal file
|
|
@ -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
|
||||
41
plugins/godoc/templates/package.txt
Normal file
41
plugins/godoc/templates/package.txt
Normal file
|
|
@ -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}}
|
||||
Loading…
Add table
Add a link
Reference in a new issue