文章目录

概述

我自从2011年开始使用自己折腾的emacs到现在, 用着它写golang时发现函数列表与补全功能不太好使,一直知道spacemacs的名声,今天想尝试下其效果如果如何,有啥奇妙之处。 我一般用它来写Golang、C、Lua、Shell、GTD和Blog,看看spacemacs是否满足我所需和习惯。

安装

Spacemacs的Github地址为:https://github.com/syl20bnr/spacemacs, 如果你的系统已装有Emacs,请先备份Emacs配置文件。因为Spacemacs的配置会覆盖掉原Emacs的配置文件。

cd ~ 
mv .emacs.d .emacs.d.bak 
mv .emacs .emacs.bak

如果你的系统没有安装Emacs,需要先安装Emacs,请注意Emacs版本至少为24.4。

安装spacemacs

git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d

启动spacemacs

emacs -mm

初次启动Spacemacs会进行初始化配置(启动时会询问使用简、全哪套配置方案),安装依赖有可能需要一段时间。 在通过命令行启动Spacemacs后,可能会发现状态栏乱码了。这是因为字体不支持的原因,需要安装Source Code Pro字体。 同时,还可能需要安装Powerline字体补丁。

配置

增加启动layers

由于我主要写Golang、C、Lua、Shell、GTD和Blog,增加相应的启动layers即可。

dotspacemacs-configuration-layers
'(
  c-c++
  go
  lua
  html
  ;; ----------------------------------------------------------------
  ;; Example of useful layers you may want to use right away.
  ;; Uncomment some layer names and press <SPC f e R> (Vim style) or
  ;; <M-m f e R> (Emacs style) to install them.
  ;; ----------------------------------------------------------------
  helm
  auto-completion
  ;; better-defaults
  emacs-lisp
  git
  markdown
  org
  ;; (shell :variables
  ;;        shell-default-height 30
  ;;        shell-default-position 'bottom)
  ;; spell-checking
  ;; syntax-checking
  ;; version-control
  )

使用

Working with Go

Go commands (start with m):

Key Binding Description
`SPC m h h` godoc at point
`SPC m i g` goto imports
`SPC m i a` add import
`SPC m i r` remove unused import
`SPC m e b` go-play buffer
`SPC m e r` go-play region
`SPC m e d` download go-play snippet
`SPC m x x` run "go run" for the current 'main' package
`SPC m g a` jump to matching test file or back from test to code file
`SPC m g c` open a clone of the current buffer with a coverage info (`go tool cover -h` for help)
`SPC m g g` go jump to definition
`SPC m r n` go rename
`SPC m t p` run "go test" for the current package
`SPC m t P` run "go test" for the current package and all packages under it
`SPC m t t` run "go test" for the function you're currently in (while you're in a \_.test.go file)
`SPC m t s` run "go test" for the suite you're currently in (requires gocheck)

Go Guru

Key Binding Description
`SPC m f d` go-guru describe symbol at point
`SPC m f f` go-guru show free variables
`SPC m f i` go-guru show implements relation
`SPC m f c` go-guru show channel sends/receives
`SPC m f r` go-guru show referrers
`SPC m f j` go-guru jump to symbol definition
`SPC m f p` go-guru show what the select expression points to
`SPC m f s` go-guru show callstack
`SPC m f e` go-guru show possible contants/types for error value
`SPC m f <` go-guru show possible callers
`SPC m f >` go-guru show call targets
`SPC m f o` go-guru set analysis scope
微信扫一扫

作者:mospan
微信关注:墨斯潘園
本文出处:http://mospany.github.io/2017/08/25/spacemacs-use-exploration/
文章版权归本人所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。