@@ -2,7 +2,23 @@ if exists("b:did_ftplugin_go_install")
2
2
finish
3
3
endif
4
4
5
- command ! - buffer -nargs =1 GoInstall call s: GoInstall (@% , <f-args> )
5
+ function ! GocodeCompletePkg (arg, cmd, index )
6
+ let s: base= DirName (@% )
7
+ let s: dirs= filter (split (globpath (s: base , a: arg .' *' ), ' \n' ), ' isdirectory(v:val)' )
8
+ let s: ndirs= len (s: dirs )
9
+
10
+ if s: ndirs <= 0
11
+ return ' '
12
+ elseif s: ndirs == 1
13
+ let s: matched= s: dirs [0 ]
14
+ else
15
+ let s: matched= s: dirs [0 ] " TODO select the next match
16
+ endif
17
+
18
+ return substitute (s: matched , s: base .' /' , ' ' , ' ' ).' /' " add a trailing / to quickly match a child
19
+ endfunction
20
+
21
+ command ! - buffer -nargs =1 -complete =custom ,GocodeCompletePkg GoInstall call s: GoInstall (@% , <f-args> )
6
22
function ! s: GoInstall (file , relpkg)
7
23
let pkg= GoRelPkg (a: file , a: relpkg )
8
24
if pkg != -1
@@ -17,7 +33,7 @@ function! s:GoInstall(file, relpkg)
17
33
endif
18
34
endfunction
19
35
20
- command ! - buffer -nargs =1 GoTest call s: GoTest (@% , <f-args> )
36
+ command ! - buffer -nargs =1 - complete = custom ,GocodeCompletePkg GoTest call s: GoTest (@% , <f-args> )
21
37
function ! s: GoTest (file , relpkg)
22
38
let pkg= GoRelPkg (a: file , a: relpkg )
23
39
if pkg != -1
0 commit comments