This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
spacemacs/layers/+lang/go/packages.el

192 lines
5.9 KiB
EmacsLisp
Raw Normal View History

2017-02-01 14:06:00 +00:00
;;; packages.el --- Go Layer packages File for Spacemacs
;;
;; Copyright (c) 2012-2020 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
(defconst go-packages
'(
company
dap-mode
(company-go :requires company)
counsel-gtags
eldoc
flycheck
(flycheck-golangci-lint :toggle (and go-use-golangci-lint
(configuration-layer/package-used-p
'flycheck)))
ggtags
helm-gtags
go-eldoc
go-fill-struct
go-gen-test
go-guru
go-impl
go-mode
go-rename
go-tag
godoctor
popwin))
2015-01-09 06:08:07 +00:00
(defun go/init-company-go ()
(use-package company-go
:defer t
:init (spacemacs|add-company-backends
:backends company-go
:modes go-mode
:variables company-go-show-annotation t)))
2018-06-11 22:05:13 +00:00
(defun go/post-init-company ()
(add-hook 'go-mode-local-vars-hook #'spacemacs//go-setup-company))
2020-03-25 16:02:29 +00:00
(defun go/pre-init-dap-mode ()
(pcase (spacemacs//go-backend)
(`lsp (add-to-list 'spacemacs--dap-supported-modes 'go-mode)))
(add-hook 'go-mode-local-vars-hook #'spacemacs//go-setup-dap))
2020-03-25 16:02:29 +00:00
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))
(defun go/post-init-flycheck ()
(spacemacs/enable-flycheck 'go-mode))
2018-06-07 19:26:51 +00:00
(defun go/init-flycheck-golangci-lint ()
(use-package flycheck-golangci-lint
:defer t
: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
: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
(progn
(spacemacs/declare-prefix-for-mode 'go-mode "mtg" "generate")
(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 ()
(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
(defun go/init-go-impl()
(use-package go-impl
:defer t
:init (spacemacs/set-leader-keys-for-major-mode 'go-mode
"ri" 'go-impl)))
(defun go/init-go-mode()
2015-01-09 06:08:07 +00:00
(use-package go-mode
:defer t
:init
(progn
;; get go packages much faster
(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)
(dolist (value '(lsp go-mode))
2018-06-11 22:05:13 +00:00
(add-to-list 'safe-local-variable-values
(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")))
:config
(progn
(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")
(spacemacs/set-leader-keys-for-major-mode 'go-mode
2018-07-27 00:01:14 +00:00
"=" 'gofmt
"eb" 'go-play-buffer
"ed" 'go-download-play
"er" 'go-play-region
"ga" 'ff-find-other-file
"gc" 'go-coverage
"hh" 'godoc-at-point
"ia" 'go-import-add
"ig" 'go-goto-imports
"ir" 'go-remove-unused-imports
"tP" 'spacemacs/go-run-package-tests-nested
"tp" 'spacemacs/go-run-package-tests
"ts" 'spacemacs/go-run-test-current-suite
"tt" 'spacemacs/go-run-test-current-function
"xx" 'spacemacs/go-run-main))))
2017-05-25 11:20:36 +00:00
(defun go/init-go-rename ()
(use-package go-rename
2018-06-09 05:11:41 +00:00
:defer t
: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
: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
:defer t
: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
(defun go/pre-init-popwin ()
(spacemacs|use-package-add-hook popwin
:post-config
(push (cons go-test-buffer-name '(:dedicated t :position bottom :stick t :noselect t :height 0.4)) popwin:special-display-config)))