2017-02-01 14:06:00 +00:00
|
|
|
;;; packages.el --- Go Layer packages File for Spacemacs
|
|
|
|
;;
|
2018-01-04 07:00:25 +00:00
|
|
|
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
|
2017-02-01 14:06:00 +00:00
|
|
|
;;
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
2015-04-19 03:40:24 +00:00
|
|
|
(setq go-packages
|
2015-10-26 13:57:33 +00:00
|
|
|
'(
|
2017-07-03 07:52:54 +00:00
|
|
|
(company-go :requires company)
|
2015-10-26 13:57:33 +00:00
|
|
|
flycheck
|
2016-05-30 02:39:21 +00:00
|
|
|
(flycheck-gometalinter :toggle (and go-use-gometalinter
|
2017-07-02 13:48:06 +00:00
|
|
|
(configuration-layer/package-used-p
|
2016-05-30 02:39:21 +00:00
|
|
|
'flycheck)))
|
2016-04-05 04:08:34 +00:00
|
|
|
ggtags
|
2017-08-26 21:18:09 +00:00
|
|
|
counsel-gtags
|
2016-04-05 04:08:34 +00:00
|
|
|
helm-gtags
|
2017-03-18 21:51:37 +00:00
|
|
|
exec-path-from-shell
|
2015-10-26 13:57:33 +00:00
|
|
|
go-eldoc
|
2016-01-18 03:06:04 +00:00
|
|
|
go-mode
|
2016-10-26 07:48:24 +00:00
|
|
|
go-guru
|
2017-02-01 14:11:52 +00:00
|
|
|
go-rename
|
2017-05-25 11:19:32 +00:00
|
|
|
godoctor
|
2017-12-05 14:48:29 +00:00
|
|
|
go-tag
|
2017-01-15 17:31:33 +00:00
|
|
|
popwin
|
2015-10-26 13:57:33 +00:00
|
|
|
))
|
2015-01-09 06:08:07 +00:00
|
|
|
|
2016-05-30 02:39:21 +00:00
|
|
|
|
2017-01-15 17:31:33 +00:00
|
|
|
(defun go/post-init-popwin ()
|
|
|
|
(push (cons go-test-buffer-name '(:dedicated t :position bottom :stick t :noselect t :height 0.4))
|
|
|
|
popwin:special-display-config))
|
|
|
|
|
2016-05-30 02:39:21 +00:00
|
|
|
(defun go/init-company-go ()
|
|
|
|
(use-package company-go
|
|
|
|
:defer t
|
|
|
|
:init
|
2017-01-02 05:39:04 +00:00
|
|
|
(spacemacs|add-company-backends
|
|
|
|
:backends company-go
|
|
|
|
:modes go-mode
|
|
|
|
:variables company-go-show-annotation t)))
|
2016-05-30 02:39:21 +00:00
|
|
|
|
2015-04-11 02:23:16 +00:00
|
|
|
(defun go/post-init-flycheck ()
|
2017-02-14 03:27:29 +00:00
|
|
|
(spacemacs/enable-flycheck 'go-mode))
|
2015-01-10 04:09:16 +00:00
|
|
|
|
2017-03-18 21:51:37 +00:00
|
|
|
(defun go/pre-init-exec-path-from-shell ()
|
|
|
|
(spacemacs|use-package-add-hook exec-path-from-shell
|
|
|
|
:pre-config
|
2017-07-09 20:02:13 +00:00
|
|
|
(dolist (var '("GOPATH" "GOROOT" "GO15VENDOREXPERIMENT") exec-path-from-shell-variables)
|
2017-03-18 21:51:37 +00:00
|
|
|
(unless (or (member var exec-path-from-shell-variables) (getenv var))
|
|
|
|
(push var exec-path-from-shell-variables)))))
|
2015-06-06 17:28:54 +00:00
|
|
|
|
2017-03-18 21:51:37 +00:00
|
|
|
(defun go/init-go-mode()
|
2015-01-09 06:08:07 +00:00
|
|
|
(use-package go-mode
|
|
|
|
:defer t
|
2016-04-05 02:36:51 +00:00
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(defun spacemacs//go-set-tab-width ()
|
|
|
|
"Set the tab width."
|
|
|
|
(setq-local tab-width go-tab-width))
|
2016-09-05 02:29:41 +00:00
|
|
|
(add-hook 'go-mode-hook 'spacemacs//go-set-tab-width))
|
2015-01-19 08:01:00 +00:00
|
|
|
:config
|
2015-04-04 04:34:03 +00:00
|
|
|
(progn
|
2015-01-19 08:01:00 +00:00
|
|
|
(add-hook 'before-save-hook 'gofmt-before-save)
|
2015-04-04 04:34:03 +00:00
|
|
|
|
2015-11-27 20:35:24 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode 'go-mode "me" "playground")
|
|
|
|
(spacemacs/declare-prefix-for-mode 'go-mode "mg" "goto")
|
|
|
|
(spacemacs/declare-prefix-for-mode 'go-mode "mh" "help")
|
|
|
|
(spacemacs/declare-prefix-for-mode 'go-mode "mi" "imports")
|
|
|
|
(spacemacs/declare-prefix-for-mode 'go-mode "mt" "test")
|
|
|
|
(spacemacs/declare-prefix-for-mode 'go-mode "mx" "execute")
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'go-mode
|
|
|
|
"hh" 'godoc-at-point
|
|
|
|
"ig" 'go-goto-imports
|
|
|
|
"ia" 'go-import-add
|
|
|
|
"ir" 'go-remove-unused-imports
|
|
|
|
"eb" 'go-play-buffer
|
|
|
|
"er" 'go-play-region
|
|
|
|
"ed" 'go-download-play
|
|
|
|
"xx" 'spacemacs/go-run-main
|
|
|
|
"ga" 'ff-find-other-file
|
2017-03-31 02:00:21 +00:00
|
|
|
"gc" 'go-coverage
|
2015-11-18 00:38:05 +00:00
|
|
|
"tt" 'spacemacs/go-run-test-current-function
|
|
|
|
"ts" 'spacemacs/go-run-test-current-suite
|
|
|
|
"tp" 'spacemacs/go-run-package-tests
|
|
|
|
"tP" 'spacemacs/go-run-package-tests-nested))))
|
2015-01-12 04:22:23 +00:00
|
|
|
|
2017-05-25 11:20:36 +00:00
|
|
|
(defun go/init-go-eldoc ()
|
2015-10-26 13:57:33 +00:00
|
|
|
(add-hook 'go-mode-hook 'go-eldoc-setup))
|
2015-01-19 08:01:00 +00:00
|
|
|
|
2017-05-25 11:20:36 +00:00
|
|
|
(defun go/init-go-guru ()
|
2016-10-18 04:17:25 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode 'go-mode "mf" "guru")
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'go-mode
|
|
|
|
"fd" 'go-guru-describe
|
|
|
|
"ff" 'go-guru-freevars
|
|
|
|
"fi" 'go-guru-implements
|
|
|
|
"fc" 'go-guru-peers
|
|
|
|
"fr" 'go-guru-referrers
|
|
|
|
"fj" 'go-guru-definition
|
|
|
|
"fp" 'go-guru-pointsto
|
|
|
|
"fs" 'go-guru-callstack
|
|
|
|
"fe" 'go-guru-whicherrs
|
|
|
|
"f<" 'go-guru-callers
|
|
|
|
"f>" 'go-guru-callees
|
|
|
|
"fo" 'go-guru-set-scope))
|
2016-01-18 03:06:04 +00:00
|
|
|
|
2017-05-25 11:20:36 +00:00
|
|
|
(defun go/init-go-rename ()
|
2016-01-18 03:06:04 +00:00
|
|
|
(use-package go-rename
|
|
|
|
:init
|
2017-05-25 11:19:32 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode 'go-mode "mr" "refactoring")
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'go-mode "rN" 'go-rename)))
|
|
|
|
|
|
|
|
(defun go/init-godoctor ()
|
|
|
|
(use-package godoctor
|
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(spacemacs/declare-prefix-for-mode 'go-mode "mr" "refactoring")
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'go-mode
|
|
|
|
"rn" 'godoctor-rename
|
|
|
|
"re" 'godoctor-extract
|
|
|
|
"rt" 'godoctor-toggle
|
|
|
|
"rd" 'godoctor-godoc))))
|
2016-04-11 14:08:56 +00:00
|
|
|
|
2017-12-05 14:48:29 +00:00
|
|
|
(defun go/init-go-tag ()
|
|
|
|
(use-package go-tag
|
|
|
|
:init
|
|
|
|
(spacemacs/declare-prefix-for-mode 'go-mode "mr" "refactoring")
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'go-mode
|
|
|
|
"rf" 'go-tag-add
|
|
|
|
"rF" 'go-tag-remove)))
|
|
|
|
|
2017-05-25 11:20:36 +00:00
|
|
|
(defun go/init-flycheck-gometalinter ()
|
2016-04-11 14:08:56 +00:00
|
|
|
(use-package flycheck-gometalinter
|
2016-04-30 02:58:23 +00:00
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(add-hook 'go-mode-hook 'spacemacs//go-enable-gometalinter t)))
|
2016-04-05 04:08:34 +00:00
|
|
|
|
|
|
|
(defun go/post-init-ggtags ()
|
2016-08-15 19:24:44 +00:00
|
|
|
(add-hook 'go-mode-local-vars-hook #'spacemacs/ggtags-mode-enable))
|
2016-04-05 04:08:34 +00:00
|
|
|
|
2017-08-26 21:18:09 +00:00
|
|
|
(defun go/post-init-counsel-gtags ()
|
|
|
|
(spacemacs/counsel-gtags-define-keys-for-mode 'go-mode))
|
|
|
|
|
2016-04-05 04:08:34 +00:00
|
|
|
(defun go/post-init-helm-gtags ()
|
|
|
|
(spacemacs/helm-gtags-define-keys-for-mode 'go-mode))
|