GoLang之再谈GvimVim配置——使用Vundle安装vim-go

GoLang之再谈GvimVim配置——使用Vundle安装vim-go,第1张

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

摘要:之前总结过在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的相关配置:

[cpp] view plain copy print ? "------------- "Vundle "https://github.com/gmarik/Vundle.vim "------------- setnocompatible"beiMproved,required filetypeoff"required "settheruntimepathtoincludeVundleandinitialize setrtp+=~/.vim/bundle/Vundle.vim callvundle#begin() "alternatively,passapathwhereVundleshouldinstallplugins "callvundle#begin('~/some/path/here') "letVundlemanageVundle,required Plugin'gmarik/Vundle.vim' "Thefollowingareexamplesofdifferentformatssupported. "KeepPlugincommandsbetweenvundle#begin/end. "pluginonGitHubrepo ""Plugin'tpope/vim-fugitive' "pluginfromhttp://vim-scripts.org/vim/scripts.HTML 'L9' "GitpluginnothostedonGitHub 'git://git.wincent.com/command-t.git' "gitreposonyourlocalmachine(i.e.whenworkingonyourownplugin) 'file:///home/gmarik/path/to/plugin' "Thesparkupvimscriptisinasubdirectoryofthisrepocalledvim. "Passthepathtosettheruntimepathproperly. 'rstacruz/sparkup',{'rtp':'vim/'} "AvoIDanameconflictwithL9 'user/L9',54); background-color:inherit">'name':'newL9'} "InstallVim-go Plugin'fatih/vim-go' "AllofyourPluginsmustbeaddedbeforethefollowingline callvundle#end()"required filetypepluginindenton"required "Toignorepluginindentchanges,insteaduse: "filetypepluginon " "BrIEfhelp ":PluginList-Listsconfiguredplugins ":PluginInstall-installsplugins;append`!`toupdateorjust:PluginUpdate ":PluginSearchfoo-searchesforfoo;append`!`torefreshlocalcache ":PluginClean-confirmsremovalofunusedplugins;append`!`toauto-approveremoval " "see:hvundleformoredetailsorwikiforFAQ "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 "thesepackagesareusedbyvim-goandcanbeautomaticallyinstalledif "neededbytheuserwithGoInstallBinarIEs lets:packages=[ \"github.com/nsf/gocode", \"code.Google.com/p/go.tools/cmd/goimports", \"code.Google.com/p/rog-go/exp/cmd/godef", \"code.Google.com/p/go.tools/cmd/oracle", \"code.Google.com/p/go.tools/cmd/gorename", \"github.com/golang/lint/golint", \"github.com/kisIElk/errcheck", \"github.com/jstemmer/goTags", \]

或者使用go get进行下载:

copy gerryyang@mba:~$gogetgithub.com/kisIElk/errcheck packagecode.Google.com/p/go.tools/go/loader:Gethttps://code.Google.com/p/go/source/checkout?repo=tools:dialtcp173.194.127.32:443:operationtimedout packagecode.Google.com/p/go.tools/go/types:Gethttps://code.Google.com/p/go/source/checkout?tools:dialtcp173.194.127.32:443:operationtimedout


如果下载失败,也可以通过gopm.io(Download Go packages with version,but no require for version control tools like Git and Hg,etc.) 根据路径单独下载。



参考

[1]Golang开发环境搭建-Vim篇

[2]Go development environment for Vim

总结

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

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

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1284621.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-09
下一篇 2022-06-09

发表评论

登录后才能评论

评论列表(0条)

保存