volgar1x/vim-gocode

Some useful commands

volgar1x opened this issue · 9 comments

Here is somme commands i'd like to implement :

  • GoInstall this command will install the current file's relative package
    example :GoInstall . -> will install current file's package
    example :GoInstall ./childpkg -> will install the current file's child package
    etc
  • GoTest this command will test the current file's relative package (same as above)
  • GoPlay this command will post current file on http://play.golang.org
  • NewGo this command will create a new golang file with a pre-inserted package depending on directory's name where the file is created
  • Edit Import to allow relatives imports
  • want some more ?

CurPkg, RelPkg and Install commands implemented in b814333

GoTest command implemented in 026060b

I'm trying to give completion to GoInstall and GoTest commands. It partially works, here is what I started :

function! GocodeCompletePkg(arg, cmd, index)
    let s:base=DirName(@%)
    let s:dirs=filter(split(globpath(s:base, a:arg.'*'), '\n'), 'isdirectory(v:val)')
    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] " TODO select the next match
    endif

    return substitute(s:matched, s:base.'/', '', '').'/' " add a trailing / to quickly match a child
endfunction

I would like to select the next match, any help will be nicely accepted :)

where is the go run?

It is not implemented yet.

first,your work is great,thx for your contribution.
here,i have a question :if this plugin will auto-install gocode in GOPATH/src/github.com/nsf/gocode. because i don't remember i have installed it there manually. the reason why i chose this plugin is that i can store all this in .vim fold and upload it to github.In this way, i can clone it back easily when i have a new machine.
thanks!

It currently does not install automatically nsf/gocode and I do not think that is the plug-in job. You can add, for yourself, in your .vimrc :

system("go install github.com/nsf/gocode")

yeah,thx

I don't think I will create new commands anymore.