]> Cypherpunks repositories - gostls13.git/commitdiff
misc/vim: Allow multiple GOOS/GOARCH.
authorYasuhiro Matsumoto <mattn.jp@gmail.com>
Tue, 2 Jul 2013 05:24:09 +0000 (15:24 +1000)
committerDavid Symonds <dsymonds@golang.org>
Tue, 2 Jul 2013 05:24:09 +0000 (15:24 +1000)
R=golang-dev, dsymonds, dominik.honnef
CC=golang-dev
https://golang.org/cl/9293043

misc/vim/autoload/go/complete.vim

index cc1013b7d335d72c1da7ac2507e4b1aa1e55e012..80fa451583afc8bfc1b37d9fdfc588fcb7b074b2 100644 (file)
@@ -32,39 +32,46 @@ function! go#complete#Package(ArgLead, CmdLine, CursorPos)
   let dirs = []
 
   if executable('go')
-      let goroot = substitute(system('go env GOROOT'), '\n', '', 'g')
-      if v:shell_error
-          echo '\'go env GOROOT\' failed'
-      endif
+    let goroot = substitute(system('go env GOROOT'), '\n', '', 'g')
+    if v:shell_error
+      echomsg '\'go env GOROOT\' failed'
+    endif
   else
-      let goroot = $GOROOT
+    let goroot = $GOROOT
   endif
 
   if len(goroot) != 0 && isdirectory(goroot)
-    let dirs += [ goroot ]
+    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
+    let dirs += workspaces
   endif
 
   if len(dirs) == 0
-      " should not happen
-      return []
+    " should not happen
+    return []
   endif
 
   let ret = {}
   for dir in dirs
-    let root = expand(dir . '/pkg/' . s:goos . '_' . s:goarch)
-    for i in split(globpath(root, 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 ret[i] = i
+    " 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(r)+1:], '[\\]', '/', 'g'), '\.a$', '', 'g')
+        let ret[i] = i
+      endfor
     endfor
   endfor
   return sort(keys(ret))