一、環(huán)境準(zhǔn)備:
系統(tǒng)環(huán)境說(shuō)明:
[root@docker golang]# cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core) [root@docker golang]# uname -a Linux docker 3.10.0-229.el7.x86_64 #1 SMP Fri Mar 6 11:36:42 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux [root@docker golang]#
準(zhǔn)備一個(gè)go文件,用于觀察配置插件過(guò)程中的變化:
//hellogolang.go package main import "fmt" func main() { fmt.Println("Hello Golang!") }
二、插件配置之路:
1、Vundle.vim:
#mkdir ~/.vim/bundle #git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
配置vimrc:創(chuàng)建~/.vimrc文件(如果你沒(méi)有這個(gè)文件的話),在文件頂部添加有關(guān)Vundle.vim的配置:
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() " let Vundle manage Vundle, required Plugin 'gmarik/Vundle.vim' " All of your Plugins must be added before the following line call vundle#end() " required filetype plugin indent on " required
此時(shí)Vim僅安裝了Vundle.vim這一個(gè)插件。編輯hellogolang.go時(shí)與編輯普通文本文件無(wú)異,一切都還是Vim的默認(rèn)屬性
2、vim-go
Vim-go是當(dāng)前使用最為廣泛的用于搭建Golang開(kāi)發(fā)環(huán)境的vim插件,這里我同樣使用vim-go作為核心和基礎(chǔ)進(jìn)行環(huán)境搭建的。vim-go利 用開(kāi)源Vim插件管理器安裝,gmarik/Vundle.vim是目前被推薦次數(shù)