Configure VIM's Go language development environment

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

This article is written for VIM like me, the use of vim-go plug-in, although the steps are simple but not enough detailed, close this article to do record and share. Welcome to the great God to correct the supplement!

In particular , this blog post is not a Go language environment build tutorial, just VIM plugin part of the configuration tutorial. If you need to know how to download and install the Go language, please configure the first half of the go language development environment.

VIM Plugin Address: github.com/fatih/vim-go

In order to facilitate the wall users, this blog all the ZIP package to download has been directly packaged: Download address

Installing pathogen

Pathogen is a plugin manager for VIM, many plugins support it, so don't be afraid of the hassle, because the steps to install it are very simple.

    1. Go to the Pathogen home page and find the latest version of the package ZIP download link below.
    2. After the download, you will get a directory named after the autoload directory to copy the files pathogen.vim to ~/.vim/autoload/pathogen.vim .
    3. Edit the ~/.vimrc file and join the row at the top call pathogen#infect() .

Installing the Vim-go Plugin

With the plugin Manager installed, you can start installing the plugins we want.

    1. Executes the ~/.vim/bundle command after entering the directory git clone https://github.com/fatih/vim-go.git .
    2. Edit ~/.vimrc the file and add the following (the last line is to disable automatic download):
onset numberlet g:go_disable_autoinstall = 0
    1. At this point, the plug-in itself has been installed, you can use according to the instructions of Github.com/fatih/vim-go, which is to point out the code to complete the <C-x><C-o> prompt, and generally need to . use after the input operator.

Installing Neocomplete real-time tips

If you want real-time code completion prompts, you can install the Neocomplete plug-in to achieve, but it has a higher requirement for VIM version, you can see its home page Github.com/shougo/neocomplete.vim.

    1. Executes the ~/.vim/bundle command after entering the directory git clone https://github.com/Shougo/neocomplete.vim.git .
    2. Edit ~/.vimrc the file and join the line let g:neocomplete#enable_at_startup = 1 . This allows you to automatically turn on real-time completion when you start VIM.

Installing Molokai Themes

The author of the Vim-go plugin also wrote a VIM Molokai theme: Github.com/fatih/molokai.

The installation process is very simple, which is to download his molokai.vim files and put them ~/.vim/colors in. ~/.vimrcyou can then add the file to the line colorscheme molokai .

Installing Tagbar

This plugin is actually optional, but looks very good, so I also think about the next.

    1. First of all decisive you need to install first ctags , I am a Mac so brew install ctags it's done.
    2. Then go get -u github.com/jstemmer/gotags install the relevant parser for the Go language.
    3. Then add the following to your ~/.vimrc file:
Let G:tagbar_Type_go = {\' Ctagstype ':' Go ', \' Kinds ': [\' P:package ', \' I:imports:1 ', \' C:constants ', \ ' v:variables ', \  ' t:types ', \  ' n:interfaces ', \  ' W:fields ', \  ' e:embedded ', \  ' m:methods ', \  ' R:constructor ', \  ' f:functions ' \], \  ' SRO ':  ' Kind2scope ': {\  ' t ':  ' n ':  ' ntype ' \}, \  ' Scope2kind ': {\  ' CType ':  ' t ', \  ' ntype ':  ' n ' \}, \  ' Ctagsbin ':  ' gotags ', \  ' Ctagsargs ':              
    1. It is time to install Tagbar plug-ins, and the installation of Vim-go, first into the ~/.vim/bundle directory. And then execute git clonehttps://github.com/majutsushi/tagbar.git .
    2. Edit ~/.vimrc the file and join the line nmap <F8> :TagbarToggle<CR> . This is a shortcut key mapping, you can change it into F8 any.

All finished is the following so domineering!

Installing the Directory Browser Nerdtree

As the saying goes, can't view the directory editor is not a good ide! In order to make our VIM look more domineering, it is absolutely impossible to miss the Nerdtree plugin.

    1. Executes the ~/.vim/bundle command after entering the directory git clone https://github.com/scrooloose/nerdtree.git .
    2. Edit ~/.vimrc the file and join the line map <C-n> :NERDTreeToggle<CR> . This way, when you need to browse the directory, you can use the shortcut keys <Ctrl+n> to bring up the browsing window.

Well, let's take a look at the final result:

Summary

Here a basic but complete configuration process is complete, you can install the Vim-go plugin documentation, set more shortcut keys, it supports a lot and very useful features. In addition, to learn how to use VIM, it is recommended that you start with a concise vim practice and practice a little bit every day as I do.

I wish you soon become the code of God, haha!

Original: http://wuwen.org/article/38/setup-vim-go-dev-environment.html

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.