Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git i/plugin/go.vim w/plugin/go.vim
- index 892d2b9..8541294 100644
- --- i/plugin/go.vim
- +++ w/plugin/go.vim
- @@ -7,22 +7,22 @@ let g:go_loaded_install = 1
- " these packages are used by vim-go and can be automatically installed if
- " needed by the user with GoInstallBinaries
- let s:packages = {
- - \ 'asmfmt': ['github.com/klauspost/asmfmt/cmd/asmfmt'],
- - \ 'errcheck': ['github.com/kisielk/errcheck'],
- - \ 'fillstruct': ['github.com/davidrjenni/reftools/cmd/fillstruct'],
- - \ 'gocode': ['github.com/nsf/gocode', {'windows': '-ldflags -H=windowsgui'}],
- - \ 'godef': ['github.com/rogpeppe/godef'],
- - \ 'gogetdoc': ['github.com/zmb3/gogetdoc'],
- - \ 'goimports': ['golang.org/x/tools/cmd/goimports'],
- - \ 'golint': ['github.com/golang/lint/golint'],
- - \ 'gometalinter': ['github.com/alecthomas/gometalinter'],
- - \ 'gomodifytags': ['github.com/fatih/gomodifytags'],
- - \ 'gorename': ['golang.org/x/tools/cmd/gorename'],
- - \ 'gotags': ['github.com/jstemmer/gotags'],
- - \ 'guru': ['golang.org/x/tools/cmd/guru'],
- - \ 'impl': ['github.com/josharian/impl'],
- - \ 'keyify': ['github.com/dominikh/go-tools/cmd/keyify'],
- - \ 'motion': ['github.com/fatih/motion'],
- + \ 'github.com/klauspost/asmfmt/cmd/asmfmt': {},
- + \ 'github.com/kisielk/errcheck': {},
- + \ 'github.com/davidrjenni/reftools/cmd/fillstruct': {},
- + \ 'github.com/nsf/gocode': {'windows': '-ldflags -H=windowsgui'},
- + \ 'github.com/rogpeppe/godef': {},
- + \ 'github.com/zmb3/gogetdoc': {},
- + \ 'golang.org/x/tools/cmd/goimports': {},
- + \ 'github.com/golang/lint/golint': {},
- + \ 'github.com/alecthomas/gometalinter': {},
- + \ 'github.com/fatih/gomodifytags': {},
- + \ 'golang.org/x/tools/cmd/gorename': {},
- + \ 'github.com/jstemmer/gotags': {},
- + \ 'golang.org/x/tools/cmd/guru': {},
- + \ 'github.com/josharian/impl': {},
- + \ 'github.com/dominikh/go-tools/cmd/keyify': {},
- + \ 'github.com/fatih/motion': {},
- \ }
- " These commands are available on any filetypes
- @@ -31,7 +31,9 @@ command! -nargs=* -complete=customlist,s:complete GoUpdateBinaries call s:GoIns
- command! -nargs=? -complete=dir GoPath call go#path#GoPath(<f-args>)
- fun! s:complete(lead, cmdline, cursor)
- - return filter(keys(s:packages), 'strpart(v:val, 0, len(a:lead)) == a:lead')
- + return filter(
- + \ map(keys(s:packages), 'fnamemodify(v:val, ":t")'),
- + \ 'strpart(v:val, 0, len(a:lead)) == a:lead')
- endfun
- " GoInstallBinaries downloads and install all necessary binaries stated in the
- @@ -87,24 +89,22 @@ function! s:GoInstallBinaries(updateBinaries, ...)
- " Filter packages from arguments (if any).
- let l:packages = {}
- if a:0 > 0
- - for l:bin in a:000
- - let l:pkg = get(s:packages, l:bin, [])
- - if len(l:pkg) == 0
- - call go#util#EchoError('unknown binary: ' . l:bin)
- - return
- - endif
- - let l:packages[l:bin] = l:pkg
- - endfor
- + let l:packages = s:filterPackages(s:packages, a:000)
- + if len(l:packages) == 0
- + return
- + endif
- else
- let l:packages = s:packages
- endif
- + return
- +
- let l:platform = ''
- if go#util#IsWin()
- let l:platform = 'windows'
- endif
- - for [basename, pkg] in items(l:packages)
- + for [pkg, opts] in items(l:packages)
- let binname = "go_" . basename . "_bin"
- let bin = basename
- @@ -120,10 +120,10 @@ function! s:GoInstallBinaries(updateBinaries, ...)
- endif
- let out = go#util#System(cmd .
- - \ (len(pkg) > 1 ? get(pkg[1], l:platform, '') : '') . ' ' .
- - \ shellescape(pkg[0]))
- + \ (len(opts) > 1 ? get(opts, l:platform, '') : '') . ' ' .
- + \ shellescape(pkg))
- if go#util#ShellError() != 0
- - echo "Error installing ". pkg[0] . ": " . out
- + echo "Error installing ". pkg . ": " . out
- endif
- endif
- endfor
- @@ -135,6 +135,24 @@ function! s:GoInstallBinaries(updateBinaries, ...)
- endif
- endfunction
- +" TODO: Show error if not found.
- +function! s:filterPackages(packages, select) abort
- + let l:ret = {}
- +
- + for [l:pkg, l:opt] in items(a:packages)
- + let l:found = 0
- + let l:bin = fnamemodify(l:pkg, ':t')
- + for l:s in a:select
- + if l:s == l:bin
- + let l:ret[l:pkg] = l:opt
- + let l:found = 1
- + break
- + endif
- + endfor
- + endfor
- + return l:ret
- +endfunction
- +
- " CheckBinaries checks if the necessary binaries to install the Go tool
- " commands are available.
- function! s:CheckBinaries()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement