Skip to content

Instantly share code, notes, and snippets.

@jimmo
Created April 19, 2016 06:53
Show Gist options
  • Save jimmo/9f73cb0b5997bce6c4d2ef438686b2f8 to your computer and use it in GitHub Desktop.
Save jimmo/9f73cb0b5997bce6c4d2ef438686b2f8 to your computer and use it in GitHub Desktop.
Minimal Go config for Emacs
;; Go
;; Requires: go get github.com/rogpeppe/godef
;; go get github.com/nsf/gocode
(defun jim-go-mode ()
;; gofmt on save.
(add-hook 'before-save-hook 'gofmt-before-save)
;; Add flymake support for go.
(require 'flymake-go)
(flymake-mode)
;; Auto-complete support
(auto-complete-mode 1)
;; Compile support
(if (not (string-match "go build" compile-command))
(set (make-local-variable 'compile-command)
"go build -v && go test -v && go vet"))
;; 8-wide tabs are too wide.
(setq tab-width 2))
(add-hook 'go-mode-hook 'jim-go-mode)
(with-eval-after-load 'go-mode
(require 'go-autocomplete))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment