Go   发布时间:2022-04-09  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了GoLang之再谈Gvim/Vim配置——使用Vundle安装vim-go大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

摘要:之前总结过在subl中使用GoLang,《GoLang及Sublime Text 2之Mac OS X 10.8.4开发环境安装》。其实goLang的安装包中已经包含了支持Vim的编写插件,配置方法很简单,可参GoLang之Gvim/Vim配置》。本文再讨论下使用Vundle如何在Vim中配置GoLang开发环境vim-go


根据Vundle的安装说明,首先安装Vundle:

$ git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim

然后对.vimrc进行配置,将Vundle的相关配置置在最开始处,下面只显示关于Vundle的相关配置:

  1. "-------------
  2. "Vundle
  3. "https://github.com/gmarik/Vundle.vim
  4. "-------------
  5. setnocompatible"beiMproved,required
  6. filetypeoff"required
  7. "settheruntimepathtoincludeVundleandinitialize
  8. setrtp+=~/.vim/bundle/Vundle.vim
  9. callvundle#begin()
  10. "alternatively,passapathwhereVundleshouldinstallplugins
  11. "callvundle#begin('~/some/path/here')
  12. "letVundlemanageVundle,required
  13. Plugin'gmarik/Vundle.vim'
  14. "Thefollowingareexamplesofdifferentformatssupported.
  15. "KeepPlugincommandsbetweenvundle#begin/end.
  16. "pluginonGitHubrepo
  17. ""Plugin'tpope/vim-fugitive'
  18. "pluginfromhttp://vim-scripts.org/vim/scripts.html
  19. 'L9'
  20. "GitpluginnothostedonGitHub
  21. 'git://git.wincent.com/command-t.git'
  22. "gitreposonyourlocalmachine(i.e.whenworkingonyourownplugin)
  23. 'file:///home/gmarik/path/to/plugin'
  24. "Thesparkupvimscriptisinasubdirectoryofthisrepocalledvim.
  25. "Passthepathtosettheruntimepathproperly.
  26. 'rstacruz/sparkup',{'rtp':'vim/'}
  27. "AvoidanameconflictwithL9
  28. 'user/L9',54); BACkground-color:inherit">'name':'newL9'}
  29. "InstallVim-go
  30. Plugin'fatih/vim-go'
  31. "AllofyourPluginsmustbeaddedbeforethefollowingline
  32. callvundle#end()"required
  33. filetypepluginindenton"required
  34. "Toignorepluginindentchanges,insteaduse:
  35. "filetypepluginon
  36. "
  37. "BriefHelp
  38. ":PluginList-listsconfiguredplugins
  39. ":PluginInstall-installsplugins;append`!`toupdateorjust:Pluginupdate
  40. ":PluginSearchfoo-searchesforfoo;append`!`torefreshlocalcache
  41. ":PluginClean-confirmsremovalofunusedplugins;append`!`toauto-approveremoval
  42. "
  43. "see:hvundlefor@H_728_37@moredetailsorwikiforFAQ
  44. "Putyournon-Pluginstuffafterthisline

其中,配置中的 Plugin 'fatih/vim-go' 告诉Vundle我们想要安装vim-go这个插件,安装方法如下:

先用vim打开任意一个go源文件(假如之前并未配置过GoLang开发环境,确保~/.vim/Syntax下没有使用vim.go,打开go的源文件后不会有对应的语法显示),例如,Hello.go。然后使用命令 :PluginInstall 就可以安装vim-go了,安装成功后会在最下面显示Done的字样。



安装好插件后,再次用vim打开Hello.go文件就可以看到vim-go插件已经生效了。




接下来的工作:(install necessary Go tools)

Please be sure all necessary binaries are installed (such asgocode,godef,goimports,etc..). You can easily install them with the included:GoInstallBinaries. Those binaries will be automatically downloaded andinstalled to your$GOBINenvironment (if not set it will use$GOPATH/bin).It requiresgitandhgfor fetching the individual Go packages.


在Vim中使用命令 :GoInstallBinaries 会使用hg下载vim-go使用的二进制工具,具体源码可以查看文件:~/.vim/bundle/vim-go/plugin/go.vim

[html] copy

大佬总结

以上是大佬教程为你收集整理的GoLang之再谈Gvim/Vim配置——使用Vundle安装vim-go全部内容,希望文章能够帮你解决GoLang之再谈Gvim/Vim配置——使用Vundle安装vim-go所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。