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:
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.
- Go to the Pathogen home page and find the latest version of the package ZIP download link below.
- After the download, you will get a directory named after the
autoload
directory to copy the files pathogen.vim
to ~/.vim/autoload/pathogen.vim
.
- 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.
- Executes the
~/.vim/bundle
command after entering the directory git clone https://github.com/fatih/vim-go.git
.
- Edit
~/.vimrc
the file and add the following (the last line is to disable automatic download):
onset numberlet g:go_disable_autoinstall = 0
- 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.
- Executes the
~/.vim/bundle
command after entering the directory git clone https://github.com/Shougo/neocomplete.vim.git
.
- 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. ~/.vimrc
you 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.
- First of all decisive you need to install first
ctags
, I am a Mac so brew install ctags
it's done.
- Then
go get -u github.com/jstemmer/gotags
install the relevant parser for the Go language.
- 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 ':
- 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
.
- 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.
- Executes the
~/.vim/bundle
command after entering the directory git clone https://github.com/scrooloose/nerdtree.git
.
- 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
[Go] Configure VIM's Go language development environment