Created
August 30, 2013 13:56
-
-
Save volgar1x/6390112 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if exists("b:did_ftplugin_go_install") | |
| finish | |
| endif | |
| function! GocodeCompletePkg(arg, cmd, index) | |
| return a:arg.'+'.a:cmd.'+'.a:index | |
| let s:dirs=split(glob(DirName(@%), a:arg.'*'), '\n') | |
| let s:ndirs=len(s:dirs) | |
| if s:ndirs <= 0 | |
| return '' | |
| elseif s:ndirs == 1 | |
| let s:matched=s:dirs[0] | |
| else | |
| let s:matched=s:dirs[0] | |
| endif | |
| return substitute(s:matched, DirName(@%).'/', '', '') | |
| endfunction | |
| command! -buffer -nargs=1 -complete=custom,GocodeCompletePkg GoInstall call s:GoInstall(@%, <f-args>) | |
| function! s:GoInstall(file, relpkg) | |
| let pkg=GoRelPkg(a:file, a:relpkg) | |
| if pkg != -1 | |
| let output=system('go install '.pkg) | |
| if !v:shell_error | |
| echo 'Package '.pkg.' installed' | |
| else | |
| echo output | |
| endif | |
| else | |
| echohl Error | echo 'You are not in a go package' | echohl None | |
| endif | |
| endfunction | |
| command! -buffer -nargs=1 -complete=custom,GocodeCompletePkg GoTest call s:GoTest(@%, <f-args>) | |
| function! s:GoTest(file, relpkg) | |
| let pkg=GoRelPkg(a:file, a:relpkg) | |
| if pkg != -1 | |
| echo system('go test '.pkg) | |
| else | |
| echohl Error | echo 'You are not in a go package' | echohl None | |
| endif | |
| endfunction | |
| let b:did_ftplugin_go_install=1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment