IDE Support Vim and Emacs

This commit is contained in:
Jiang Bian
2012-08-23 15:42:37 +08:00
parent 135d62b771
commit 492ddae582
3 changed files with 109 additions and 14 deletions

123
1.4.md
View File

@@ -1,6 +1,6 @@
#1.4 GO开发工具
本节我将介绍个开发工具它们都具有自动化提示自动化fmt功能,因为它们都是跨平台的,所以安装步骤之类的都是通用的。
本节我将介绍个开发工具它们都具有自动化提示自动化fmt功能,因为它们都是跨平台的,所以安装步骤之类的都是通用的。
##liteide
@@ -34,19 +34,19 @@
1.打开之后安装 Package Control:ctrl+` 打开命令行,执行如下代码
import urllib2,os; pf='Package Control.sublime- package';pp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else
None;urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http:// sublime.wbond.net/'+pf.replace(' ','%20')).read()); print 'Please restart Sublime Text to finish installation'
import urllib2,os; pf='Package Control.sublime- package';pp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else
None;urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http:// sublime.wbond.net/'+pf.replace(' ','%20')).read()); print 'Please restart Sublime Text to finish installation'
这个时候你重启一下sublimetext可以发现在在菜单栏多了一个如下的栏目,说明package control已经安装成功了
![](images/1.4.sublime3.png?raw=true)
2.接下来安装gocode https://github.com/nsf/gocode
打开终端运行如下代码
go get -u github.com/nsf/gocode
go get -u github.com/DisposaBoy/MarGo
打开终端运行如下代码
go get -u github.com/nsf/gocode
go get -u github.com/DisposaBoy/MarGo
这个时候我们会发现在gopath/bin下面多了两个可执行文件gocode和margo这两个文件会在gosublime起来的时候自动启动
3.安装完之后就可以安装sublimetext的插件了安装gosublime、sidebar(增强边栏)安装插件之后记得重启sublimetext生效,ctrl+shift+p打开package controll 输入pcip
@@ -64,10 +64,105 @@
如果没有出现这样的提示一般就是你的path没有配置正确你可以打开终端输入gocode是不是能够正确运行如果不行就说明path没有配置正确
## links
* [目录](<preface.md>)
* 上一节: [Go Shell命令](<1.3.md>)
* 下一节: [总结](<1.5.md>)
## LastModified
## Vim
Vim是从vi发展出来的一个文本编辑器, 代码补完、编译及错误跳转等方便编程的功能特别丰富,在程序员中被广泛使用。
![](images/1.4.vim.png?raw=true)
1. 配置vim高亮显示
cp -r $GOROOT/misc/vim/* ~/.vim/
2. 在~/.vimrc文件中增加语法高亮显示
filetype plugin indent on
syntax on
3. 安装gocode
go get -u github.com/nsf/gocode
gocode默认安装到$GOPATH/bin里面下面需要把$GOPATH/bin路径设置到系统PATH里面。
4. 配置gocode
~ cd $GOPATH/src/github.com/nsf/gocode/vim
~ /update.bash
~ gocode set propose-builtins true
propose-builtins true
~ gocode set lib-path "/home/border/gocode/pkg/linux_amd64"
lib-path "/home/border/gocode/pkg/linux_amd64"
~ gocode set
propose-builtins true
lib-path "/home/border/gocode/pkg/linux_amd64"
5. 恭喜你,安装程序,你现在可以使用 <C-x><C-o> 体验一下开发Go的乐趣.
## Emacs
Emacs传说中的神器她不仅仅是一个编辑器它是一个整合环境或可称它为集成开发环境这些功能如让使用者置身于全功能的操作系统中
![](images/1.4.emacs.png?raw=true)
1. 配置Emacs高亮显示
cp $GOROOT/misc/emacs/* ~/.emacs.d/
2. 安装Gocode
go get -u github.com/nsf/gocode
gocode默认安装到$GOPATH/bin里面下面需要把$GOPATH/bin路径设置到系统PATH里面。
3. 配置gocode
~ cd $GOPATH/src/github.com/nsf/gocode/emacs
~ cp go-autocomplete.el ~/.emacs.d/
~ gocode set propose-builtins true
propose-builtins true
~ gocode set lib-path "/home/border/gocode/pkg/linux_amd64" // 换为你自己的路径
lib-path "/home/border/gocode/pkg/linux_amd64"
~ gocode set
propose-builtins true
lib-path "/home/border/gocode/pkg/linux_amd64"
4. 需要安装 Auto completion [AutoCompletion](http://www.emacswiki.org/emacs/AutoComplete)
* 下载AutoComplete并解压
~ make install DIR=$HOME/.emacs.d/auto-complete
* 配置~/.emacs文件
;;auto-complete
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/auto-complete/ac-dict")
(ac-config-default)
(local-set-key (kbd "M-/") 'semantic-complete-analyze-inline)
(local-set-key "." 'semantic-complete-self-insert)
(local-set-key ">" 'semantic-complete-self-insert)
* 详细信息参考: http://www.emacswiki.org/emacs/AutoComplete
5. 配置.emacs
;; golang mode
(require 'go-mode-load)
(require 'go-autocomplete)
(require 'auto-complete-config)
6. 恭喜你你现在可以体验在神器中开发Go的乐趣.
## links
* [目录](<preface.md>)
* 上一节: [Go Shell命令](<1.3.md>)
* 下一节: [总结](<1.5.md>)
## LastModified
* $Id$

BIN
images/1.4.emacs.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
images/1.4.vim.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB