Golang on the Gvim/vim configuration--Using Vundle installation Vim-go

Source: Internet
Author: User
Tags sublime text gocode
This is a creation in Article, where the information may have evolved or changed.

2014-11-09 WCDJ


Summary : Previously summarized in SUBL using Golang, "Golang and Sublime Text 2 mac OS X 10.8.4 Development Environment Installation". In fact, Golang's installation package already contains support for VIM writing plug-ins, configuration method is very simple, can refer to the "Golang gvim/vim configuration". This article discusses how to configure the Golang development environment Vim-go in VIM using Vundle.


According to Vundle installation instructions, first install the Vundle:

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

The. VIMRC is then configured to place the relevant configuration of the Vundle at the very beginning, and only the relevant configuration about Vundle is shown below:

"-------------" Vundle "Https://github.com/gmarik/Vundle.vim"-------------set nocompatible "be improved, R Equiredfiletype off "required" set the runtime path to include Vundle and Initializeset Rtp+=~/.vim/bund Le/vundle.vimcall Vundle#begin () "Alternatively, pass a path where vundle should install plugins" Call Vundle#begin (' ~/som E/path/here ') "Let Vundle manage Vundle, requiredplugin ' Gmarik/vundle.vim '" The following is examples of different forma TS supported. " Keep Plugin commands between vundle#begin/end. "Plugin on GitHub Repo" "Plugin ' tpope/vim-fugitive '" Plugin from Http://vim -scripts.org/vim/scripts.html "" Plugin ' L9 ' "Git Plugin not hosted on GitHub" "Plugin" git://git.wincent.com/ Command-t.git ' "Git repos on your local machine (i.e. when working on your own plugin)" "Plugin" file:///home/gmarik/path/t O/plugin ' "The Sparkup vim script is in a subdirectory of this repo called Vim." Pass the path to set the Runtimepath properly. Plugin ' rstacruz/sParkup ', {' RTP ': ' vim/'} "Avoid a name conflict with L9" "Plugin ' user/l9 ', {' name ': ' NewL9 '}" Install Vim-goplugin ' fatih/  Vim-go ' All of your Plugins must be added before the following Linecall Vundle#end () "Requiredfiletype plugin       Indent on ' required ' to ignore plugin indent changes, instead use: ' FileType plugin on ' "Brief Help":P luginlist -Lists configured plugins ":P Lugininstall-installs plugins; Append '! ' to update or just:P luginupdate ":P luginsearch foo-searches for foo; Append '! ' to refresh local cache ':P luginclean-confirms removal of unused plugins; Append '! ' to Auto-approve removal "" See:h vundle for more details or wiki for FAQ "Put your non-plugin stuff after this Line

wherein, the configuration of Plugin ' Fatih/vim-go ' tells Vundle we want to install vim-go this plugin, the installation method is as follows:

First use VIM to open any go source file (if you have not previously configured the Golang development environment, to ensure that ~/.vim/syntax does not use Vim.go, open the source file of Go will not have a corresponding syntax display), for example, Hello.go. You can then use the command:P lugininstall to install the vim-go, and the successful installation will show the word done at the bottom.



After installing the plugin, the Hello.go file can be opened again with vim to see that the Vim-go plugin is already in effect.




Next work: (Install necessary Go tools)

Sure all necessary binaries is installed (such as,, gocode godef goimports , etc.). You can easily install them with the included :GoInstallBinaries . Those binaries'll is automatically downloaded andinstalled to your $GOBIN environment (if not set it'll use $GOPATH/bin ). It requires and for git hg fetching the individual Go packages.


Use the command in VIM: Goinstallbinaries will use HG to download vim-go used binary tools, the specific source can view the file: ~/.vim/bundle/vim-go/plugin/go.vim

"These packages is used by Vim-go and can is automatically installed if" needed by the user with Goinstallbinarieslet s: 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 ",            \]

Or use go get to download:

gerryyang@mba:~ $go get github.com/kisielk/errcheckpackage code.google.com/p/go.tools/go/loader:get https:// Code.google.com/p/go/source/checkout?repo=tools:dial TCP 173.194.127.32:443:operation timed Outpackage Code.google.com/p/go.tools/go/types:get https://code.google.com/p/go/source/checkout?repo=tools:dial TCP 173.194.127.32:443:operation timed out


If the download fails, you can also pass Gopm.io (Download Go packages with version, but no require for version control tools like Git and Hg, etc.) root Download the data path separately.



Reference

[1] Golang Development Environment Building-vim Chapter

[2] Go development environment for Vim



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.