2017-06-08 11:47:56 +02:00
|
|
|
;;; lang/go/config.el -*- lexical-binding: t; -*-
|
2015-06-15 09:06:10 +02:00
|
|
|
|
2017-02-23 00:06:12 -05:00
|
|
|
(def-package! go-mode
|
2015-06-15 09:06:10 +02:00
|
|
|
:mode "\\.go$"
|
|
|
|
:interpreter "go"
|
2017-05-25 20:11:24 +02:00
|
|
|
:config
|
2017-05-26 02:13:47 +02:00
|
|
|
(setq gofmt-command "goimports")
|
|
|
|
|
2017-04-17 02:17:10 -04:00
|
|
|
(add-hook 'go-mode-hook #'flycheck-mode)
|
2017-05-26 02:13:47 +02:00
|
|
|
|
|
|
|
(if (not (executable-find "goimports"))
|
|
|
|
(warn "go-mode: couldn't find goimports; no code formatting/fixed imports on save")
|
|
|
|
(add-hook! go-mode (add-hook 'before-save-hook #'gofmt-before-save nil t)))
|
2017-05-25 20:11:24 +02:00
|
|
|
|
2017-04-17 02:17:10 -04:00
|
|
|
(set! :build 'go-build 'go-mode #'+go/build)
|
|
|
|
(set! :repl 'go-mode #'gorepl-run)
|
2017-02-19 18:57:16 -05:00
|
|
|
|
2017-02-23 00:06:12 -05:00
|
|
|
(map! :map go-mode-map
|
2017-04-17 02:17:10 -04:00
|
|
|
:n "gd" #'go-guru-definition
|
|
|
|
:n "gD" #'go-guru-referrers
|
2015-11-30 05:31:20 -05:00
|
|
|
(:localleader
|
2017-04-17 02:17:10 -04:00
|
|
|
:n "gr" #'go-play-buffer
|
|
|
|
:v "gr" #'go-play-region
|
2017-03-19 22:49:00 -04:00
|
|
|
(:prefix "f"
|
2017-04-17 02:17:10 -04:00
|
|
|
:n "i" #'go-goto-imports
|
|
|
|
:n "h" #'godoc-at-point
|
|
|
|
:n "d" #'go-guru-describe
|
|
|
|
:n "v" #'go-guru-freevars
|
|
|
|
:n "I" #'go-guru-implements
|
|
|
|
:n "p" #'go-guru-peers
|
|
|
|
:n "r" #'go-guru-referrers
|
|
|
|
:n "t" #'go-guru-pointsto
|
|
|
|
:n "s" #'go-guru-callstack
|
|
|
|
:n "e" #'go-guru-whicherrs
|
|
|
|
:n "c" #'go-guru-callers
|
|
|
|
:n "C" #'go-guru-callees)
|
2017-03-19 22:49:00 -04:00
|
|
|
(:prefix "r"
|
2017-04-17 02:17:10 -04:00
|
|
|
:n "a" #'go-import-add
|
|
|
|
:n "i" #'go-remove-unused-imports
|
|
|
|
:nv "f" #'gofmt)
|
2017-03-19 22:49:00 -04:00
|
|
|
(:prefix "t"
|
2017-04-17 02:17:10 -04:00
|
|
|
:n "r" #'+go/test-rerun
|
|
|
|
:n "a" #'+go/test-all
|
|
|
|
:n "s" #'+go/test-single
|
|
|
|
:n "n" #'+go/test-nested))))
|
2017-03-19 22:49:00 -04:00
|
|
|
|
|
|
|
|
2017-05-26 11:44:06 +02:00
|
|
|
(def-package! go-eldoc
|
|
|
|
:after go-mode
|
|
|
|
:commands go-eldoc-setup
|
|
|
|
:config (add-hook 'go-mode-hook #'go-eldoc-setup))
|
|
|
|
|
|
|
|
|
2017-03-19 22:49:00 -04:00
|
|
|
(def-package! go-guru
|
|
|
|
:commands (go-guru-describe go-guru-freevars go-guru-implements go-guru-peers
|
|
|
|
go-guru-referrers go-guru-definition go-guru-pointsto
|
|
|
|
go-guru-callstack go-guru-whicherrs go-guru-callers go-guru-callees
|
2017-05-26 02:13:47 +02:00
|
|
|
go-guru-expand-region)
|
|
|
|
:config
|
|
|
|
(unless (executable-find "guru")
|
|
|
|
(warn "go-mode: couldn't find guru, refactoring commands won't work")))
|
2017-02-19 18:57:16 -05:00
|
|
|
|
|
|
|
|
2017-05-26 11:44:06 +02:00
|
|
|
(def-package! gorepl-mode
|
|
|
|
:commands (gorepl-run gorepl-run-load-current-file)
|
|
|
|
:config
|
|
|
|
(unless (executable-find "gore")
|
|
|
|
(warn "go-mode: couldn't find gore, REPL support disabled")))
|
|
|
|
|
|
|
|
|
2017-03-16 17:40:45 -04:00
|
|
|
(def-package! company-go
|
2017-06-02 23:54:07 +03:00
|
|
|
:init (setq command-go-gocode-command "gocode")
|
2017-03-19 22:47:50 -04:00
|
|
|
:when (featurep! :completion company)
|
2017-03-16 17:40:45 -04:00
|
|
|
:after go-mode
|
2017-05-26 02:13:47 +02:00
|
|
|
:config
|
|
|
|
(if (executable-find command-go-gocode-command)
|
|
|
|
(set! :company-backend 'go-mode '(company-go))
|
|
|
|
(warn "go-mode: couldn't find gocode, code completion won't work")))
|