mirror of
https://github.com/golang/go
synced 2024-11-21 22:24: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:
parent
6d2d4ba94f
commit
efced7c6e9
@ -34,7 +34,7 @@ function! go#complete#Package(ArgLead, CmdLine, CursorPos)
|
||||
if executable('go')
|
||||
let goroot = substitute(system('go env GOROOT'), '\n', '', 'g')
|
||||
if v:shell_error
|
||||
echo '\'go env GOROOT\' failed'
|
||||
echomsg '\'go env GOROOT\' failed'
|
||||
endif
|
||||
else
|
||||
let goroot = $GOROOT
|
||||
@ -44,7 +44,11 @@ function! go#complete#Package(ArgLead, CmdLine, CursorPos)
|
||||
let dirs += [goroot]
|
||||
endif
|
||||
|
||||
let workspaces = split($GOPATH, ':')
|
||||
let pathsep = ':'
|
||||
if s:goos == 'windows'
|
||||
let pathsep = ';'
|
||||
endif
|
||||
let workspaces = split($GOPATH, pathsep)
|
||||
if workspaces != []
|
||||
let dirs += workspaces
|
||||
endif
|
||||
@ -56,16 +60,19 @@ function! go#complete#Package(ArgLead, CmdLine, CursorPos)
|
||||
|
||||
let ret = {}
|
||||
for dir in dirs
|
||||
let root = expand(dir . '/pkg/' . s:goos . '_' . s:goarch)
|
||||
for i in split(globpath(root, a:ArgLead.'*'), "\n")
|
||||
" this may expand to multiple lines
|
||||
let root = split(expand(dir . '/pkg/' . s:goos . '_' . s:goarch), "\n")
|
||||
for r in root
|
||||
for i in split(globpath(r, a:ArgLead.'*'), "\n")
|
||||
if isdirectory(i)
|
||||
let i .= '/'
|
||||
elseif i !~ '\.a$'
|
||||
continue
|
||||
endif
|
||||
let i = substitute(substitute(i[len(root)+1:], '[\\]', '/', 'g'), '\.a$', '', 'g')
|
||||
let i = substitute(substitute(i[len(r)+1:], '[\\]', '/', 'g'), '\.a$', '', 'g')
|
||||
let ret[i] = i
|
||||
endfor
|
||||
endfor
|
||||
endfor
|
||||
return sort(keys(ret))
|
||||
endfunction
|
||||
|
Loading…
Reference in New Issue
Block a user