小甲鱼 发表于 2016-8-22 02:57:02

安装 vim-go,打造 Go 语言专用 IDE

安装 vim-go,打造 Go 语言专用 IDE

工欲善其事,必先利其器!讲的就是一个小男孩成长为大男人的故事……

不好意思,小甲鱼又跑题了 {:10_283:}

那个 vim-go 是目前最好的 go 语言开发环境最好的 vim 插件,安装它需要两个步骤:


[*]安装 vim 插件管理器 Vundle
[*]通过 Vundle 安装 vim-go 插件


安装 vim 插件管理器 Vundle


执行下面命令(不要切换到 root 账号):

git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
执行 vi ~/.vimrc 命令,输入下边代码:

set nocompatible            " be iMproved, required
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'

" Install vim-go
Plugin 'fatih/vim-go'

" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList       - lists configured plugins
" :PluginInstall    - installs plugins; append `!` to update or just
" :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean      - 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

通过 Vundle 安装 vim-go 插件


保存退出后,再次执行 vim 命令启动 vim,按下冒号(:),并输入 PluginInstall 命令:



可以看到开始安装了(如果打开 vim 报错,请检查上边的 .vimrc 文件是不是与网页一模一样,细心ing),直到左下角出现 Done 字样,表明安装完成:



重新打开你的 go 源代码,可以看到界面已经焕然一新:




安装相关二进制工具


再次执行 vim 命令启动 vim,按下冒号(:),并输入 GoInstallBinaries,Go 会自动安装相关的二进制工具,这些工具安装后会出现 GOPATH 目录下的 bin 文件夹里面。

好吧,因为一些不可描述的原因,你输入 :GoInstallBinaries 命令之后可能一直得不到响应……
如果是酱紫,不要气馁,我早猜到了 {:10_248:},戳右边(如果你可以正常安装,请忽略) -> 当 GoInstallBinaries 失败之后……


接下来你可能还需要学习:

1. GOPATH 与工作空间

2. vim-go 插件使用教程

hldh214 发表于 2016-8-22 09:07:00

同类型的还有 GOSublime
目前使用的 pycharm 安装了 Go 插件

~风介~ 发表于 2016-8-22 10:24:54

其实,如果不输入中文的话,Vim还真的是任何语言的编程利器。{:10_254:}

n毫升空针 发表于 2016-10-21 15:10:36

vim好强大...

eimlfang 发表于 2018-3-3 00:50:54

为了不想被vim劝退,我选择了vscode,发现还是不错的,对go的支持挺好的~真,不想再次被vim劝退
页: [1]
查看完整版本: 安装 vim-go,打造 Go 语言专用 IDE