Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.79 KB | None | 0 0
  1. diff --git i/plugin/go.vim w/plugin/go.vim
  2. index 892d2b9..8541294 100644
  3. --- i/plugin/go.vim
  4. +++ w/plugin/go.vim
  5. @@ -7,22 +7,22 @@ let g:go_loaded_install = 1
  6. " these packages are used by vim-go and can be automatically installed if
  7. " needed by the user with GoInstallBinaries
  8. let s:packages = {
  9. - \ 'asmfmt': ['github.com/klauspost/asmfmt/cmd/asmfmt'],
  10. - \ 'errcheck': ['github.com/kisielk/errcheck'],
  11. - \ 'fillstruct': ['github.com/davidrjenni/reftools/cmd/fillstruct'],
  12. - \ 'gocode': ['github.com/nsf/gocode', {'windows': '-ldflags -H=windowsgui'}],
  13. - \ 'godef': ['github.com/rogpeppe/godef'],
  14. - \ 'gogetdoc': ['github.com/zmb3/gogetdoc'],
  15. - \ 'goimports': ['golang.org/x/tools/cmd/goimports'],
  16. - \ 'golint': ['github.com/golang/lint/golint'],
  17. - \ 'gometalinter': ['github.com/alecthomas/gometalinter'],
  18. - \ 'gomodifytags': ['github.com/fatih/gomodifytags'],
  19. - \ 'gorename': ['golang.org/x/tools/cmd/gorename'],
  20. - \ 'gotags': ['github.com/jstemmer/gotags'],
  21. - \ 'guru': ['golang.org/x/tools/cmd/guru'],
  22. - \ 'impl': ['github.com/josharian/impl'],
  23. - \ 'keyify': ['github.com/dominikh/go-tools/cmd/keyify'],
  24. - \ 'motion': ['github.com/fatih/motion'],
  25. + \ 'github.com/klauspost/asmfmt/cmd/asmfmt': {},
  26. + \ 'github.com/kisielk/errcheck': {},
  27. + \ 'github.com/davidrjenni/reftools/cmd/fillstruct': {},
  28. + \ 'github.com/nsf/gocode': {'windows': '-ldflags -H=windowsgui'},
  29. + \ 'github.com/rogpeppe/godef': {},
  30. + \ 'github.com/zmb3/gogetdoc': {},
  31. + \ 'golang.org/x/tools/cmd/goimports': {},
  32. + \ 'github.com/golang/lint/golint': {},
  33. + \ 'github.com/alecthomas/gometalinter': {},
  34. + \ 'github.com/fatih/gomodifytags': {},
  35. + \ 'golang.org/x/tools/cmd/gorename': {},
  36. + \ 'github.com/jstemmer/gotags': {},
  37. + \ 'golang.org/x/tools/cmd/guru': {},
  38. + \ 'github.com/josharian/impl': {},
  39. + \ 'github.com/dominikh/go-tools/cmd/keyify': {},
  40. + \ 'github.com/fatih/motion': {},
  41. \ }
  42.  
  43. " These commands are available on any filetypes
  44. @@ -31,7 +31,9 @@ command! -nargs=* -complete=customlist,s:complete GoUpdateBinaries call s:GoIns
  45. command! -nargs=? -complete=dir GoPath call go#path#GoPath(<f-args>)
  46.  
  47. fun! s:complete(lead, cmdline, cursor)
  48. - return filter(keys(s:packages), 'strpart(v:val, 0, len(a:lead)) == a:lead')
  49. + return filter(
  50. + \ map(keys(s:packages), 'fnamemodify(v:val, ":t")'),
  51. + \ 'strpart(v:val, 0, len(a:lead)) == a:lead')
  52. endfun
  53.  
  54. " GoInstallBinaries downloads and install all necessary binaries stated in the
  55. @@ -87,24 +89,22 @@ function! s:GoInstallBinaries(updateBinaries, ...)
  56. " Filter packages from arguments (if any).
  57. let l:packages = {}
  58. if a:0 > 0
  59. - for l:bin in a:000
  60. - let l:pkg = get(s:packages, l:bin, [])
  61. - if len(l:pkg) == 0
  62. - call go#util#EchoError('unknown binary: ' . l:bin)
  63. - return
  64. - endif
  65. - let l:packages[l:bin] = l:pkg
  66. - endfor
  67. + let l:packages = s:filterPackages(s:packages, a:000)
  68. + if len(l:packages) == 0
  69. + return
  70. + endif
  71. else
  72. let l:packages = s:packages
  73. endif
  74.  
  75. + return
  76. +
  77. let l:platform = ''
  78. if go#util#IsWin()
  79. let l:platform = 'windows'
  80. endif
  81.  
  82. - for [basename, pkg] in items(l:packages)
  83. + for [pkg, opts] in items(l:packages)
  84. let binname = "go_" . basename . "_bin"
  85.  
  86. let bin = basename
  87. @@ -120,10 +120,10 @@ function! s:GoInstallBinaries(updateBinaries, ...)
  88. endif
  89.  
  90. let out = go#util#System(cmd .
  91. - \ (len(pkg) > 1 ? get(pkg[1], l:platform, '') : '') . ' ' .
  92. - \ shellescape(pkg[0]))
  93. + \ (len(opts) > 1 ? get(opts, l:platform, '') : '') . ' ' .
  94. + \ shellescape(pkg))
  95. if go#util#ShellError() != 0
  96. - echo "Error installing ". pkg[0] . ": " . out
  97. + echo "Error installing ". pkg . ": " . out
  98. endif
  99. endif
  100. endfor
  101. @@ -135,6 +135,24 @@ function! s:GoInstallBinaries(updateBinaries, ...)
  102. endif
  103. endfunction
  104.  
  105. +" TODO: Show error if not found.
  106. +function! s:filterPackages(packages, select) abort
  107. + let l:ret = {}
  108. +
  109. + for [l:pkg, l:opt] in items(a:packages)
  110. + let l:found = 0
  111. + let l:bin = fnamemodify(l:pkg, ':t')
  112. + for l:s in a:select
  113. + if l:s == l:bin
  114. + let l:ret[l:pkg] = l:opt
  115. + let l:found = 1
  116. + break
  117. + endif
  118. + endfor
  119. + endfor
  120. + return l:ret
  121. +endfunction
  122. +
  123. " CheckBinaries checks if the necessary binaries to install the Go tool
  124. " commands are available.
  125. function! s:CheckBinaries()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement