Golang vim开发环境设置
1 简介 上一篇博客我们介绍了Golang的安装、编译、运行,本篇博客我们介绍如何设置面向Golang的vim开发环境。原生的vim无法自行识别golang关键字,开发环境如同编辑普通文本文件,无法高亮显示,更不要说自动补全等功能。为此,我们需要在vim中加入面向golang的插件vim-go。同时,根据vim-go的安装引导,我们还需要安装YouCompleteMe(YCM)。 2 安装Vundle Vundle的git页面https://github.com/VundleVim/Vundle.vim gitclonehttps://github.com/gmarik/Vundle.vim.git~/.vim/bundle/Vundle.vim 3 安装vim-go vim-go的git页面 https://github.com/fatih/vim-go gitclonehttps://github.com/fatih/vim-go.git~/.vim/bundle/vim-go 4 安装YCM YCM的git页面 https://github.com/Valloric/YouCompleteMe 4.1 前提条件 vim版本7.3.584以上 安装依赖 sudoapt-getinstallbuild-essentialcmake sudoapt-getinstallpython-dev 4.2 git clone gitclonehttps://github.com/Valloric/YouCompleteMe.git~/.vim/bundle/YouCompleteMe 4.3 编译安装 进入~/.vim/bundle/YouCompleteMe目录,执行 gitsubmoduleupdate--init--recursive ./install.py?clang-completer?gocode-completer 这两条命令执行时间较长,尤其第一条,可以并行做点别的。 5 配置 编辑~/.vimrc "------------- "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 ""Plugin'L9' "GitpluginnothostedonGitHub ""Plugin'git://git.wincent.com/command-t.git' "gitreposonyourlocalmachine(i.e.whenworkingonyourownplugin) ""Plugin'file:///home/gmarik/path/to/plugin' "Thesparkupvimscriptisinasubdirectoryofthisrepocalledvim. "Passthepathtosettheruntimepathproperly. ""Plugin'rstacruz/sparkup',{'rtp':'vim/'} "AvoidanameconflictwithL9 ""Plugin'user/L9',{'name':'newL9'} "InstallVim-go Plugin'fatih/vim-go' "InstallYCM Plugin'Valloric/YouCompleteMe' "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 setsmarttab setshiftwidth=4 settabstop=4 setsofttabstop=4 setexpandtab autocmdFileTypegosetexpandtab 6 参考 https://github.com/gmarik/Vundle.vim http://studygolang.com/articles/2927 https://github.com/fatih/vim-go http://howiefh.github.io/2015/05/22/vim-install-youcompleteme-plugin/ https://github.com/Valloric/YouCompleteMe (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |