1
0
mirror of https://github.com/golang/go synced 2024-11-21 21:34:40 -07:00

misc/vim: Allow multiple GOOS/GOARCH.

R=golang-dev, dsymonds, dominik.honnef
CC=golang-dev
https://golang.org/cl/9293043
This commit is contained in:
Yasuhiro Matsumoto 2013-07-02 15:24:09 +10:00 committed by David Symonds
parent 6d2d4ba94f
commit efced7c6e9

View File

@ -32,39 +32,46 @@ function! go#complete#Package(ArgLead, CmdLine, CursorPos)
let dirs = [] let dirs = []
if executable('go') if executable('go')
let goroot = substitute(system('go env GOROOT'), '\n', '', 'g') let goroot = substitute(system('go env GOROOT'), '\n', '', 'g')
if v:shell_error if v:shell_error
echo '\'go env GOROOT\' failed' echomsg '\'go env GOROOT\' failed'
endif endif
else else
let goroot = $GOROOT let goroot = $GOROOT
endif endif
if len(goroot) != 0 && isdirectory(goroot) if len(goroot) != 0 && isdirectory(goroot)
let dirs += [ goroot ] let dirs += [goroot]
endif endif
let workspaces = split($GOPATH, ':') let pathsep = ':'
if s:goos == 'windows'
let pathsep = ';'
endif
let workspaces = split($GOPATH, pathsep)
if workspaces != [] if workspaces != []
let dirs += workspaces let dirs += workspaces
endif endif
if len(dirs) == 0 if len(dirs) == 0
" should not happen " should not happen
return [] return []
endif endif
let ret = {} let ret = {}
for dir in dirs for dir in dirs
let root = expand(dir . '/pkg/' . s:goos . '_' . s:goarch) " this may expand to multiple lines
for i in split(globpath(root, a:ArgLead.'*'), "\n") let root = split(expand(dir . '/pkg/' . s:goos . '_' . s:goarch), "\n")
if isdirectory(i) for r in root
let i .= '/' for i in split(globpath(r, a:ArgLead.'*'), "\n")
elseif i !~ '\.a$' if isdirectory(i)
continue let i .= '/'
endif elseif i !~ '\.a$'
let i = substitute(substitute(i[len(root)+1:], '[\\]', '/', 'g'), '\.a$', '', 'g') continue
let ret[i] = i endif
let i = substitute(substitute(i[len(r)+1:], '[\\]', '/', 'g'), '\.a$', '', 'g')
let ret[i] = i
endfor
endfor endfor
endfor endfor
return sort(keys(ret)) return sort(keys(ret))