您的位置:首页 > 编程语言 > Go语言

vim自动补全:go

2015-12-18 12:56 495 查看
1 环境配置

export GOPATH=/home/go


2 在新建GOPATH下新建三个目录

mkdir src pkg bin


src 存放源码
pkg 存放编译生成的文件
bin 存放生成的可执行文件

3 工具安装

安装goimports
go get github.com/bradfitz/goimports


安装gocode
go get github.com/nsf/gocode


安装godef
go get code.google.com/p/rog-go/exp/cmd/godef


4、安装vbundle(安装git:apt-get install git)

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


5、

a) Add following commands to the head of ~/.vimrc.

set nocompatible               " be iMproved
filetype off                   " required!
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle
" required!
Bundle 'gmarik/vundle'
filetype plugin indent on
syntax on


b) Install vim-go

~$ cd ~/.vim/bundle
~$ git clone https://github.com/fatih/vim-go.git[/code] 
Add this line to ~/.vimrc.

Plugin 'fatih/vim-go'


Execute :PluginInstall in Vim.

6、更新

cd $GOPATH/src/github.com/nsf/gocode && vim/update.sh
gocode set propose-builtins true
gocode set lib-path "$GOPATH/pkg/linux_amd64"


7、打开vim,自动补全功能快捷键(ctrl+x+o)

为了方便,将 Ctrl+Space 映射为自动补全快捷键:

imap <C-Space> <C-x><C-o>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: