summary refs log tree commit diff
path: root/emacs.d/modules/module-go.el
blob: 19f40db03dc88dce2acd843f3f2a958bb20a0391 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
(require 'config-package)

(use-package go-mode
  :mode (("\\.go\\'" . go-mode))
  :bind ("C-z" . hydra-go/body))

(use-package go-eldoc
  :config
  (add-hook 'go-mode-hook 'go-eldoc-setup))

(use-package gotest)

(use-package go-guru)

(use-package go-imports)

(use-package golint)

(use-package go-projectile)

(use-package company-go
  :config
  (add-hook 'go-mode-hook (lambda() (add-to-list 'company-backends 'company-go))))

(defun fc/my-go-hook ()
  (set (make-local-variable 'compile-command)
       "go build -v && go test -v && go vet")
  (setq-local tab-width 2))

(add-hook 'before-save-hook 'gofmt-before-save)
(add-hook 'go-mode-hook 'fc/my-go-hook)
(add-hook 'go-mode-hook 'company-mode)

(defhydra hydra-go (:hint nil :exit t)
"
^Command^      ^Imports^       ^Doc^
^-------^------^-------^-------^---^
_r_: run      _ig_: goto       _d_: doc at point
_g_: guru     _ia_: add
^  ^          _ir_: remove
"
  ("g" 'hydra-go-guru/body :color blue)
  ("r" go-run-main)
  ("d" godoc-at-point)
  ("ig" go-goto-imports )
  ("ia" go-import-add)
  ("ir" go-remove-unused-imports)
  ("q" nil "quit" :color blue))

(provide 'module-go)