-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
_gocode
171 lines (156 loc) · 6.6 KB
/
_gocode
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#compdef gocode
# -----------------------------------------------------------------------------
# The BSD-3-Clause License
#
# Copyright (c) 2016, Koichi Shiraishi
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * Neither the name of que nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# -----------------------------------------------------------------------------
#
# github.com/nsf/gocode
#
# -----------------------------------------------------------------------------
#
# Usage: gocode [-s] [-f=<format>] [-in=<path>] [-sock=<type>] [-addr=<addr>]
# <command> [<args>]
#
# Flags:
# -addr string
# address for tcp socket (default "127.0.0.1:37373")
# -debug
# enable server-side debug mode
# -f string
# output format (vim | emacs | nice | csv | csv-with-package | json) (default "nice")
# -in string
# use this file instead of stdin input
# -profile int
# port on which to expose profiling information for pprof; 0 to disable profiling
# -s run a server instead of a client
# -sock string
# socket type (unix | tcp) (default "unix")
#
# Commands:
# autocomplete [<path>] <offset> main autocompletion command
# close close the gocode daemon
# drop-cache drop gocode daemon's cache
# options list config options (extended)
# set [<name> [<value>]] list or set config options
# status gocode daemon status report
#
# -----------------------------------------------------------------------------
function _gocode() {
local context curcontext=$curcontext state line ret=1
declare -A opt_args
local -a commands
commands=(
'autocomplete:main autocompletion command' # [<path>] <offset>
'close:close the gocode daemon'
"drop-cache:drop gocode daemon's cache"
'options:list config options (extended)'
'set:list or set config options' # [<name> [<value>]]
'status:gocode daemon status report'
)
_arguments -C \
'-addr[address for tcp socket]:tcp address (default "127.0.0.1\:37373"):addr' \
'-debug[enable server-side debug mode]' \
'-f[output format]:output format (default "nice"):(vim emacs nice csv csv-with-package json)' \
'-in[use this file instead of stdin input]:input file:_files' \
'-profile[port on which to expose profiling information for pprof; 0 to disable profiling]' \
'-s[run a server instead of a client]' \
'-sock[socket type]:socket type (default "unix"):(unix tcp)' \
"1: :{_describe 'gocode command' commands}" \
'*:: :->args' \
&& ret=0
case $words[1] in
set)
local -a set_options
set_options=(
'propose-builtins:If set to true, gocode will add built-in types, functions and constants to autocompletion proposals.'
'lib-path:Allows you to add search paths for packages.'
'custom-pkg-prefix:set custom pkg prefix'
'custom-vendor-dir:set custom vendor dir'
'autobuild:try to automatically build out-of-date packages when their source files are modified, in order to obtain the freshest autocomplete results for them.'
'force-debug-output:forcefully redirect the logging into that file. Also forces enabling of the debug mode on the server side.'
'package-lookup-mode:package lookup rules.'
'close-timeout:gocode terminate duration.'
'unimported-packages:try to import certain known packages automatically for identifiers which cannot be resolved otherwise.'
'partials:not filter autocompletion results based on entered prefix before the cursor.'
'ignore-case:perform case-insensitive matching when doing prefix-based filtering.'
"class-filtering:performs class-based filtering if partial input matches corresponding class keyword: const, var, type, func, package."
)
_arguments \
"1: :{_describe 'set options' set_options}" \
'*:: :->args' \
&& ret=0
case $state in
(args)
case $words[1] in
(propose-builtins|autobuild|unimported-packages|partials|ignore-case|class-filtering)
local -a boolean_option
boolean_option=(
'true:enable feature'
'false:disable features'
)
_arguments \
"*: :{_describe 'boolean' boolean_option}"
;;
lib-path)
_arguments \
'*::library paths:_files'
;;
custom-pkg-prefix)
_arguments \
'*::custom pkg prefix'
;;
custom-vendor-dir)
_arguments \
'*::custom vendor dir:_files'
;;
package-lookup-mode)
local -a lookup_mode
lookup_mode=(
'go:standard Go package lookup rules.'
'gb:gb-specific lookup rules.'
'bazel:bazel specific lookup rules.'
)
_arguments \
"*: :{_describe 'package lookup mode' lookup_mode}"
;;
close-timeout)
_arguments \
'*::timeout seconds' \
;;
esac
;;
esac
;;
esac
return ret
}
_gocode "$*"
# vim:ft=zsh:et:sts=2:sw=2