Mac下的Sublime Text 3 安装go插件GoSublime, SideBarEnhancements,Go Build,Godef

0. 安装ST3(Sublime Text 3) 和 Package Control

a.修改hosts,添加一行(该死的GFW):

50.116.34.243 sublime.wbond.net

b.安装两个库先:

$go get github.con/nsf/gocode
$go get github.com/slene/margo(很多参考文章里面提到的github.com/DisposaBoy/MarGo已经不存在了)

$mv $GOPATH/bin/margo $GOPATH/bin/Margo

c.安装Sublime Text 3(build 3065)

http://www.sublimetext.com/3


d.ST3(Sublime Text 3)里面:
control+`
输入下面这行,回车安装Package Control:
import urllib.request,os,hashlib; h = '7183a2d3e96f11eeadd761d777e62404' + 'e330c659d4bb41d3bdf022e94cab3cd0'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)


1、GoSublime

a.shift+commond+p

ip(Package Control:Install Package)
等待自动更新可用列表之后,
选择 GoSublime


b.
Preferences->Package Settings->GoSublime->Settings-Default
"env": {},
变成:
"env": {"GOPATH":"/Users/wenke/go"},


2、SideBarEnhancements
重复1a,选择 SideBarEnhancements



3.Go Build(网上提到的Sublime Text 2版本的Package木有了)
a.Tools->Build System->New Build System


b.
{
"shell_cmd": "make"
}
变成
{
"shell_cmd": "go run $file"
}


另存为 goBuild


c.Tools->Build System->将默认勾选的Automatic 改成 goBuild


d.打开main.go,commond+b,下面弹出一个窗口,出现显示运行结果!

Mac下的Sublime Text 3 安装go插件GoSublime, SideBarEnhancements,Go Build,Godef_第1张图片


4.Godef (added 20141208 代码跳转,margo的super+.,super+g只能跳转到定义处,不能跳转回来.可自定义快捷键跟LiteIDE一样的热键,保持一致的使用习惯)

说明: http://blog.buaa.us/godef-plugin-for-sublime-released/ 

a. 安装过程参考 https://github.com/buaazp/Godef

b.Preferences->Package Settings->Godef->Settings-User

{
    "gopath": "/usr/local/Cellar/go/1.1.2/libexec:/Users/wenke/go"
}


c.Preferences->Package Settings->Godef->Key Bindings-Default

[
    { "keys": ["shift+super+j"], "command": "godef" }
]


d.Preferences->Package Settings->Godef->Key Bindings-User

[
{ "keys": ["alt+super+right"], "command": "jump_forward"},
{ "keys": ["alt+super+left"], "command": "jump_back"},
]


你可能感兴趣的:(Go)