-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlang-go.el
More file actions
40 lines (33 loc) · 1.13 KB
/
lang-go.el
File metadata and controls
40 lines (33 loc) · 1.13 KB
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
(use-package go-mode
:config
; Use goimports instead of go-fmt
(setq gofmt-command "goimports")
(add-hook 'go-mode-hook 'company-mode)
;; Call Gofmt before saving
(add-hook 'before-save-hook 'gofmt-before-save)
(add-hook 'go-mode-hook 'setup-go-mode-compile)
(add-hook 'go-mode-hook #'smartparens-mode)
(add-hook 'go-mode-hook '(lambda ()
(local-set-key (kbd "C-c C-r") 'go-remove-unused-imports)))
(add-hook 'go-mode-hook '(lambda ()
(local-set-key (kbd "C-c C-g") 'go-goto-imports)))
(add-hook 'go-mode-hook (lambda ()
(set (make-local-variable 'company-backends) '(company-go))
(company-mode))))
(use-package company-go
:after go-mode
:config
(setq tab-width 4)
:bind (:map go-mode-map
; Godef jump key binding
("M-." . godef-jump)))
(use-package flymake-go)
(use-package go-eldoc
:config
(add-hook 'go-mode-hook 'go-eldoc-setup))
(defun setup-go-mode-compile ()
; Customize compile command to run go build
(if (not (string-match "go" compile-command))
(set (make-local-variable 'compile-command)
"go build -v && go test -v && go vet")))
(provide 'lang-go)