2017-06-08 11:47:56 +02:00
|
|
|
;;; lang/go/config.el -*- lexical-binding: t; -*-
|
2015-06-15 09:06:10 +02:00
|
|
|
|
2018-03-02 19:55:03 -05:00
|
|
|
;;
|
|
|
|
;; Plugins
|
|
|
|
;;
|
2018-03-01 00:55:58 -05:00
|
|
|
|
2018-05-25 00:46:11 +02:00
|
|
|
(after! go-mode
|
2018-06-15 03:15:34 +02:00
|
|
|
(set-env! "GOPATH" "GOROOT")
|
2018-06-15 16:07:24 +02:00
|
|
|
(set-repl-handler! 'go-mode #'gorepl-run)
|
2018-06-15 17:27:48 +02:00
|
|
|
(set-lookup-handlers! 'go-mode
|
2017-10-03 02:49:49 +02:00
|
|
|
:definition #'go-guru-definition
|
|
|
|
:references #'go-guru-referrers
|
|
|
|
:documentation #'godoc-at-point)
|
|
|
|
|
2018-08-22 02:15:44 +02:00
|
|
|
(set-formatter! 'go-mode #'gofmt)
|
2018-05-25 00:46:11 +02:00
|
|
|
(when-let* ((goimports (executable-find "goimports")))
|
|
|
|
(setq gofmt-command goimports))
|
2018-05-26 10:33:55 +02:00
|
|
|
(when (featurep! :feature syntax-checker)
|
2018-06-21 15:54:36 +02:00
|
|
|
(setq gofmt-show-errors nil)) ; Leave it to flycheck
|
2018-05-25 00:46:11 +02:00
|
|
|
|
2018-05-26 10:33:55 +02:00
|
|
|
(add-hook 'go-mode-hook #'go-eldoc-setup)
|
2018-02-14 05:52:07 -05:00
|
|
|
|
2017-10-03 02:49:49 +02:00
|
|
|
(def-menu! +go/refactor-menu
|
|
|
|
"Refactoring commands for `go-mode' buffers."
|
|
|
|
'(("Add import" :exec go-import-add :region nil)
|
|
|
|
("Remove unused imports" :exec go-remove-unused-imports :region nil)
|
|
|
|
("Format buffer (gofmt)" :exec go-gofmt))
|
|
|
|
:prompt "Refactor: ")
|
|
|
|
|
|
|
|
(def-menu! +go/build-menu
|
|
|
|
"Build/compilation commands for `go-mode' buffers."
|
|
|
|
'(("Build project" :exec "go build")
|
|
|
|
("Build & run project" :exec "go run")
|
|
|
|
("Clean files" :exec "go clean"))
|
|
|
|
:prompt "Run test: ")
|
|
|
|
|
|
|
|
(def-menu! +go/test-menu
|
|
|
|
"Test commands for `go-mode' buffers."
|
|
|
|
'(("Last test" :exec +go/test-rerun)
|
|
|
|
("All tests" :exec +go/test-all)
|
|
|
|
("Single test" :exec +go/test-single)
|
|
|
|
("Nested test" :exec +go/test-nested))
|
|
|
|
:prompt "Run test: ")
|
|
|
|
|
|
|
|
(def-menu! +go/help-menu
|
|
|
|
"Help and information commands for `go-mode' buffers."
|
|
|
|
'(("Go to imports" :exec go-goto-imports)
|
|
|
|
("Lookup in godoc" :exec godoc-at-point)
|
|
|
|
("Describe this" :exec go-guru-describe)
|
|
|
|
("List free variables" :exec go-guru-freevars)
|
|
|
|
("What does this point to" :exec go-guru-pointsto)
|
|
|
|
("Implements relations for package types" :exec go-guru-implements :region nil)
|
|
|
|
("List peers for channel" :exec go-guru-peers)
|
|
|
|
("List references to object" :exec go-guru-referrers)
|
|
|
|
("Which errors" :exec go-guru-whicerrs)
|
|
|
|
("What query" :exec go-guru-what)
|
|
|
|
("Show callers of this function" :exec go-guru-callers :region nil)
|
|
|
|
("Show callees of this function" :exec go-guru-callees :region nil)))
|
2017-02-19 18:57:16 -05:00
|
|
|
|
2017-02-23 00:06:12 -05:00
|
|
|
(map! :map go-mode-map
|
2017-10-03 02:49:49 +02:00
|
|
|
:localleader
|
2018-02-14 05:53:53 -05:00
|
|
|
:nr "r" #'+go/refactor-menu
|
|
|
|
:n "b" #'+go/build-menu
|
|
|
|
:n "h" #'+go/help-menu
|
|
|
|
:n "t" #'+go/test-menu
|
|
|
|
:n "r" #'go-play-buffer
|
|
|
|
:v "r" #'go-play-region))
|
2017-03-19 22:49:00 -04:00
|
|
|
|
|
|
|
|
2017-05-26 11:44:06 +02:00
|
|
|
(def-package! gorepl-mode
|
2018-05-25 00:46:11 +02:00
|
|
|
:commands gorepl-run-load-current-file)
|
2017-05-26 11:44:06 +02:00
|
|
|
|
|
|
|
|
2017-03-16 17:40:45 -04:00
|
|
|
(def-package! company-go
|
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
|
2018-06-15 02:58:12 +02:00
|
|
|
(set-company-backend! 'go-mode 'company-go)
|
2018-05-25 00:46:11 +02:00
|
|
|
(setq company-go-show-annotation t))
|