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
|
|
|
'(
|
2018-06-11 22:05:13 +00:00
|
|
|
company
|
2017-07-03 07:52:54 +00:00
|
|
|
(company-go :requires company)
|
2018-06-09 04:58:50 +00:00
|
|
|
counsel-gtags
|
2019-11-15 16:47:31 +00:00
|
|
|
eldoc
|
2015-10-26 13:57:33 +00:00
|
|
|
flycheck
|
2019-09-04 20:37:58 +00:00
|
|
|
(flycheck-golangci-lint :toggle (and go-use-golangci-lint
|
2018-06-07 19:26:51 +00:00
|
|
|
(configuration-layer/package-used-p
|
|
|
|
'flycheck)))
|
2016-04-05 04:08:34 +00:00
|
|
|
ggtags
|
|
|
|
helm-gtags
|
2015-10-26 13:57:33 +00:00
|
|
|
go-eldoc
|
2018-06-09 04:58:50 +00:00
|
|
|
go-fill-struct
|
2018-06-09 04:34:40 +00:00
|
|
|
go-gen-test
|
2016-10-26 07:48:24 +00:00
|
|
|
go-guru
|
2018-04-11 11:54:35 +00:00
|
|
|
go-impl
|
2018-06-09 04:58:50 +00:00
|
|
|
go-mode
|
2017-02-01 14:11:52 +00:00
|
|
|
go-rename
|
2017-12-05 14:48:29 +00:00
|
|
|
go-tag
|
2018-06-09 04:58:50 +00:00
|
|
|
godoctor
|
2019-04-07 06:38:15 +00:00
|
|
|
popwin))
|
2015-01-09 06:08:07 +00:00
|
|
|
|
2016-05-30 02:39:21 +00:00
|
|
|
(defun go/init-company-go ()
|
|
|
|
(use-package company-go
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2018-06-09 05:09:11 +00:00
|
|
|
:init (spacemacs|add-company-backends
|
|
|
|
:backends company-go
|
|
|
|
:modes go-mode
|
|
|
|
:variables company-go-show-annotation t)))
|
2016-05-30 02:39:21 +00:00
|
|
|
|
2018-06-11 22:05:13 +00:00
|
|
|
(defun go/post-init-company ()
|
|
|
|
(add-hook 'go-mode-local-vars-hook #'spacemacs//go-setup-company))
|
|
|
|
|
2018-06-09 04:58:50 +00:00
|
|
|
(defun go/post-init-counsel-gtags ()
|
|
|
|
(spacemacs/counsel-gtags-define-keys-for-mode 'go-mode))
|
|
|
|
|
2019-11-15 16:47:31 +00:00
|
|
|
(defun go/post-init-eldoc ()
|
|
|
|
(add-hook 'go-mode-hook #'spacemacs//go-setup-eldoc))
|
|
|
|
|
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
|
|
|
|
2018-06-07 19:26:51 +00:00
|
|
|
(defun go/init-flycheck-golangci-lint ()
|
|
|
|
(use-package flycheck-golangci-lint
|
|
|
|
:defer t
|
2019-09-04 20:37:58 +00:00
|
|
|
:init (add-hook 'go-mode-hook 'spacemacs//go-enable-flycheck-golangci-lint t)))
|
2018-06-07 19:26:51 +00:00
|
|
|
|
2018-06-09 04:58:50 +00:00
|
|
|
(defun go/post-init-ggtags ()
|
|
|
|
(add-hook 'go-mode-local-vars-hook #'spacemacs/ggtags-mode-enable))
|
|
|
|
|
|
|
|
(defun go/post-init-helm-gtags ()
|
|
|
|
(spacemacs/helm-gtags-define-keys-for-mode 'go-mode))
|
|
|
|
|
|
|
|
(defun go/init-go-eldoc ()
|
2019-11-15 16:47:31 +00:00
|
|
|
(use-package go-eldoc :defer t))
|
2018-06-09 04:58:50 +00:00
|
|
|
|
|
|
|
(defun go/init-go-fill-struct ()
|
|
|
|
(use-package go-fill-struct
|
2018-06-09 05:11:41 +00:00
|
|
|
:defer t
|
2018-06-09 05:09:11 +00:00
|
|
|
:init (spacemacs/set-leader-keys-for-major-mode 'go-mode
|
|
|
|
"rs" 'go-fill-struct)))
|
2018-06-09 04:58:50 +00:00
|
|
|
|
|
|
|
(defun go/init-go-gen-test()
|
|
|
|
(use-package go-gen-test
|
2018-06-09 05:11:41 +00:00
|
|
|
:defer t
|
2018-06-09 04:58:50 +00:00
|
|
|
:init
|
2018-06-09 05:09:11 +00:00
|
|
|
(progn
|
2019-04-07 06:38:15 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode 'go-mode "mtg" "generate")
|
2018-06-09 05:09:11 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'go-mode
|
|
|
|
"tgg" 'go-gen-test-dwim
|
|
|
|
"tgf" 'go-gen-test-exported
|
|
|
|
"tgF" 'go-gen-test-all))))
|
2018-06-09 04:58:50 +00:00
|
|
|
|
|
|
|
(defun go/init-go-guru ()
|
2018-06-09 05:09:11 +00:00
|
|
|
(use-package go-impl
|
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(spacemacs/declare-prefix-for-mode 'go-mode "mf" "guru")
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'go-mode
|
|
|
|
"f<" 'go-guru-callers
|
|
|
|
"f>" 'go-guru-callees
|
|
|
|
"fc" 'go-guru-peers
|
|
|
|
"fd" 'go-guru-describe
|
|
|
|
"fe" 'go-guru-whicherrs
|
|
|
|
"ff" 'go-guru-freevars
|
|
|
|
"fi" 'go-guru-implements
|
|
|
|
"fj" 'go-guru-definition
|
|
|
|
"fo" 'go-guru-set-scope
|
|
|
|
"fp" 'go-guru-pointsto
|
|
|
|
"fr" 'go-guru-referrers
|
|
|
|
"fs" 'go-guru-callstack))))
|
2018-06-09 04:58:50 +00:00
|
|
|
|
2018-04-11 11:54:35 +00:00
|
|
|
(defun go/init-go-impl()
|
|
|
|
(use-package go-impl
|
2018-06-09 05:09:11 +00:00
|
|
|
:defer t
|
2018-04-11 11:54:35 +00:00
|
|
|
:init (spacemacs/set-leader-keys-for-major-mode 'go-mode
|
|
|
|
"ri" 'go-impl)))
|
|
|
|
|
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
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2016-04-05 02:36:51 +00:00
|
|
|
:init
|
|
|
|
(progn
|
2018-06-09 04:43:52 +00:00
|
|
|
;; get go packages much faster
|
2018-06-09 05:10:03 +00:00
|
|
|
(setq go-packages-function 'spacemacs/go-packages-gopkgs)
|
2018-06-11 22:05:13 +00:00
|
|
|
(add-hook 'go-mode-hook 'spacemacs//go-set-tab-width)
|
|
|
|
(add-hook 'go-mode-local-vars-hook
|
|
|
|
#'spacemacs//go-setup-backend)
|
2018-08-12 14:59:50 +00:00
|
|
|
(dolist (value '(lsp go-mode))
|
2018-06-11 22:05:13 +00:00
|
|
|
(add-to-list 'safe-local-variable-values
|
2019-04-01 21:48:10 +00:00
|
|
|
(cons 'go-backend value)))
|
|
|
|
(spacemacs|add-toggle go-test-verbose
|
|
|
|
:documentation "Enable verbose test output."
|
|
|
|
:status go-test-verbose
|
|
|
|
:on (setq go-test-verbose t)
|
|
|
|
:off (setq go-test-verbose nil)
|
|
|
|
:evil-leader-for-mode (go-mode . "tv")))
|
2015-01-19 08:01:00 +00:00
|
|
|
:config
|
2015-04-04 04:34:03 +00:00
|
|
|
(progn
|
2018-07-26 23:05:02 +00:00
|
|
|
(when go-format-before-save
|
|
|
|
(add-hook 'before-save-hook 'gofmt-before-save))
|
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")
|
2018-06-09 04:58:50 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode 'go-mode "mr" "refactoring")
|
2015-11-27 20:35:24 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode 'go-mode "mt" "test")
|
2019-02-11 15:52:04 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode 'go-mode "mT" "toggle")
|
2015-11-27 20:35:24 +00:00
|
|
|
(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
|
2018-07-27 00:01:14 +00:00
|
|
|
"=" 'gofmt
|
2015-11-18 00:38:05 +00:00
|
|
|
"eb" 'go-play-buffer
|
|
|
|
"ed" 'go-download-play
|
2018-06-09 05:09:11 +00:00
|
|
|
"er" 'go-play-region
|
2015-11-18 00:38:05 +00:00
|
|
|
"ga" 'ff-find-other-file
|
2017-03-31 02:00:21 +00:00
|
|
|
"gc" 'go-coverage
|
2018-06-09 05:09:11 +00:00
|
|
|
"hh" 'godoc-at-point
|
|
|
|
"ia" 'go-import-add
|
|
|
|
"ig" 'go-goto-imports
|
|
|
|
"ir" 'go-remove-unused-imports
|
|
|
|
"tP" 'spacemacs/go-run-package-tests-nested
|
2015-11-18 00:38:05 +00:00
|
|
|
"tp" 'spacemacs/go-run-package-tests
|
2018-06-09 05:09:11 +00:00
|
|
|
"ts" 'spacemacs/go-run-test-current-suite
|
|
|
|
"tt" 'spacemacs/go-run-test-current-function
|
|
|
|
"xx" 'spacemacs/go-run-main))))
|
2015-01-12 04:22:23 +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
|
2018-06-09 05:11:41 +00:00
|
|
|
:defer t
|
2018-06-09 05:09:11 +00:00
|
|
|
:init (spacemacs/set-leader-keys-for-major-mode 'go-mode
|
|
|
|
"rN" 'go-rename)))
|
2017-05-25 11:19:32 +00:00
|
|
|
|
2018-06-09 04:58:50 +00:00
|
|
|
(defun go/init-go-tag ()
|
|
|
|
(use-package go-tag
|
2018-06-09 05:11:41 +00:00
|
|
|
:defer t
|
2018-06-09 05:09:11 +00:00
|
|
|
:init (spacemacs/set-leader-keys-for-major-mode 'go-mode
|
|
|
|
"rf" 'go-tag-add
|
|
|
|
"rF" 'go-tag-remove)))
|
2018-06-09 04:58:50 +00:00
|
|
|
|
2017-05-25 11:19:32 +00:00
|
|
|
(defun go/init-godoctor ()
|
|
|
|
(use-package godoctor
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2018-06-09 05:09:11 +00:00
|
|
|
:init (spacemacs/set-leader-keys-for-major-mode 'go-mode
|
|
|
|
"rd" 'godoctor-godoc
|
|
|
|
"re" 'godoctor-extract
|
|
|
|
"rn" 'godoctor-rename
|
|
|
|
"rt" 'godoctor-toggle)))
|
2016-04-11 14:08:56 +00:00
|
|
|
|
2018-06-09 04:58:50 +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))
|