Emacs: Go mode skeletons, compiler, formatter

master
Pierre Neidhardt 2014-10-23 16:44:23 +02:00
parent 6bed055e86
commit a053a8e7b9
2 changed files with 27 additions and 0 deletions

View File

@ -85,6 +85,7 @@ Example: to assign some-function to C-i, use
(load-external "\\.vert\\'\\|\\.frag\\'\\|\\.glsl\\'" 'glsl-mode nil 'c-mode)
(load-external "\\.go\\'" 'go-mode)
(add-hook 'go-mode-hook (lambda () (require 'mode-go)))
(load-external "\\.dot\\'" 'graphviz-dot-mode)
(add-hook 'graphviz-dot-mode-hook (lambda () (require 'mode-dot)))

26
.emacs.d/mode-go.el Normal file
View File

@ -0,0 +1,26 @@
;;==============================================================================
;; Go
;;==============================================================================
(add-hook-and-eval
'go-mode-hook
(lambda ()
(add-hook 'before-save-hook #'gofmt-before-save nil t)
(local-set-key (kbd "C-c m") 'go-main)
(set (make-local-variable 'compile-command) (concat "go run " buffer-file-name))))
(define-skeleton go-main
"Insert main function with basic includes."
nil
> "package main
import (
\"fmt\"
)
func main () {" \n
> @ _ \n
"}" > \n)
(provide 'mode-go)