Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Ohmyzsh
Commits
9e9b790f
Commit
9e9b790f
authored
Sep 08, 2015
by
Ilia Choly
Browse files
golang: improve go doc completion
parent
9c08641d
Changes
3
Show whitespace changes
Inline
Side-by-side
plugins/golang/golang.plugin.zsh
View file @
9e9b790f
...
@@ -54,23 +54,37 @@ __go_tool_complete() {
...
@@ -54,23 +54,37 @@ __go_tool_complete() {
'-installsuffix[suffix to add to package directory]:suffix'
'-installsuffix[suffix to add to package directory]:suffix'
'-tags[list of build tags to consider satisfied]:tags'
'-tags[list of build tags to consider satisfied]:tags'
)
)
__go_list
()
{
__go_packages
()
{
local
expl importpaths
_path_files
-W
"
$(
go
env
GOROOT
)
/src"
-/
declare
-a
importpaths
_path_files
-W
"
$(
go
env
GOPATH
)
/src"
-/
importpaths
=(
$(
go list
${
words
[
$CURRENT
]
}
... 2>/dev/null
)
)
}
_wanted importpaths expl
'import paths'
compadd
"
$@
"
-
"
${
importpaths
[@]
}
"
__go_identifiers
()
{
compadd
$(
godoc
-templates
$ZSH
/plugins/golang/templates
${
words
[-2]
}
2> /dev/null
)
}
}
case
${
words
[2]
}
in
case
${
words
[2]
}
in
clean|doc
)
doc
)
_arguments
-s
-w
:
'*:importpaths:__go_list'
_arguments
-s
-w
\
"-c[symbol matching honors case (paths not affected)]"
\
"-cmd[show symbols with package docs even if package is a command]"
\
"-u[show unexported symbols as well as exported]"
\
"2:importpaths:__go_packages"
\
":next identifiers:__go_identifiers"
;;
clean
)
_arguments
-s
-w
\
"-i[remove the corresponding installed archive or binary (what 'go install' would create)]"
\
"-n[print the remove commands it would execute, but not run them]"
\
"-r[apply recursively to all the dependencies of the packages named by the import paths]"
\
"-x[print remove commands as it executes them]"
\
"*:importpaths:__go_packages"
;;
;;
fix|fmt|list|vet
)
fix|fmt|list|vet
)
_alternative
':importpaths:__go_
list
'
':files:_path_files -g "*.go"'
_alternative
':importpaths:__go_
packages
'
':files:_path_files -g "*.go"'
;;
;;
install
)
install
)
_arguments
-s
-w
:
${
build_flags
[@]
}
\
_arguments
-s
-w
:
${
build_flags
[@]
}
\
"-v[show package names]"
\
"-v[show package names]"
\
'*:importpaths:__go_
list
'
'*:importpaths:__go_
packages
'
;;
;;
get
)
get
)
_arguments
-s
-w
:
\
_arguments
-s
-w
:
\
...
@@ -81,7 +95,7 @@ __go_tool_complete() {
...
@@ -81,7 +95,7 @@ __go_tool_complete() {
${
build_flags
[@]
}
\
${
build_flags
[@]
}
\
"-v[show package names]"
\
"-v[show package names]"
\
"-o[output file]:file:_files"
\
"-o[output file]:file:_files"
\
"*:args:{ _alternative ':importpaths:__go_
list
' ':files:_path_files -g
\"
*.go
\"
' }"
"*:args:{ _alternative ':importpaths:__go_
packages
' ':files:_path_files -g
\"
*.go
\"
' }"
;;
;;
test
)
test
)
_arguments
-s
-w
:
\
_arguments
-s
-w
:
\
...
@@ -103,7 +117,7 @@ __go_tool_complete() {
...
@@ -103,7 +117,7 @@ __go_tool_complete() {
"-cpuprofile[write CPU profile to file]:file:_files"
\
"-cpuprofile[write CPU profile to file]:file:_files"
\
"-memprofile[write heap profile to file]:file:_files"
\
"-memprofile[write heap profile to file]:file:_files"
\
"-memprofilerate[set heap profiling rate]:number"
\
"-memprofilerate[set heap profiling rate]:number"
\
"*:args:{ _alternative ':importpaths:__go_
list
' ':files:_path_files -g
\"
*.go
\"
' }"
"*:args:{ _alternative ':importpaths:__go_
packages
' ':files:_path_files -g
\"
*.go
\"
' }"
;;
;;
help
)
help
)
_values
"
${
commands
[@]
}
"
\
_values
"
${
commands
[@]
}
"
\
...
...
plugins/golang/templates/package.txt
0 → 100644
View file @
9e9b790f
{{with .PDoc}}{{/*
Constants
---------------------------------------
*/}}{{with .Consts}}{{range .}}{{range .Names}}{{.}} {{end}}{{end}}{{end}}{{/*
Variables
---------------------------------------
*/}}{{with .Vars}}{{range .}}{{range .Names}}{{.}} {{end}}{{end}}{{end}}{{/*
Functions
---------------------------------------
*/}}{{with .Funcs}}{{range .}}{{ .Name }} {{end}}{{end}}{{/*
Types
---------------------------------------
*/}}{{with .Types}}{{range .}}{{ $TypeName := .Name }}{{ $TypeName }} {{/*
*/}}{{range .Methods}}{{ $TypeName }}.{{.Name}} {{end}}{{/*
*/}}{{range .Funcs}}{{.Name}} {{end}}{{/*
*/}}{{range .Consts}}{{range .Names}}{{.}} {{end}}{{end}}{{/*
*/}}{{range .Vars}}{{range .Names}}{{.}} {{end}}{{end}}{{end}}{{end}}{{end}}
plugins/golang/templates/search.txt
0 → 100644
View file @
9e9b790f
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment