您的当前位置:首页正文

vim自动补全:go

2023-05-21 来源:爱站旅游
导读vim自动补全:go
vim⾃动补全:go

1 环境配置

export GOPATH=/home/go

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

mkdir src pkg bin

src 存放源码

pkg 存放编译⽣成的⽂件bin 存放⽣成的可执⾏⽂件3 ⼯具安装

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

安装 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 iMprovedfiletype off \" required!set rtp+=~/.vim/bundle/vundle/call vundle#rc()

\" let Vundle manage Vundle\" required!

Bundle 'gmarik/vundle'filetype plugin indent onsyntax on

b) Install vim-go

~$ cd ~/.vim/bundle

~$ git clone https://github.com/fatih/vim-go.git

Add this line to ~/.vimrc.

Plugin 'fatih/vim-go'

Execute :PluginInstall in Vim. 6、更新

cd $GOPATH/src/github.com/nsf/gocode && vim/update.shgocode set propose-builtins true

gocode set lib-path \"$GOPATH/pkg/linux_amd64\"

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

为了⽅便,将 Ctrl+Space 映射为⾃动补全快捷键:imap

因篇幅问题不能全部显示,请点此查看更多更全内容