Skip to content

Commit

Permalink
[go] Switch layer variables to defcustoms
Browse files Browse the repository at this point in the history
and fix wrong declaration of go-mode hooks
  • Loading branch information
smile13241324 committed Apr 17, 2021
1 parent b3bf5c1 commit 247d059
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 35 deletions.
64 changes: 37 additions & 27 deletions layers/+lang/go/config.el
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,52 @@

(spacemacs|define-jump-handlers go-mode godef-jump)

(defvar go-backend (if (configuration-layer/layer-used-p 'lsp) 'lsp 'go-mode)
(spacemacs|defc go-backend (if (configuration-layer/layer-used-p 'lsp) 'lsp 'go-mode)
"The backend to use for IDE features.
Possible values are `go-mode' and `lsp'.
If `nil' then `go-mode' is the default backend unless `lsp' layer is used.")
(put 'go-backend 'safe-local-variable #'symbolp)
Possible values are `lsp' and `go-mode'.
If not set then `go-mode' is the default backend unless `lsp' layer is used."
'(choice (const lsp) (const go-mode)) nil #'symbolp)

(defvar go-use-gocheck-for-testing nil
"If using gocheck for testing when running the tests -check.f will be used instead of -run to specify the test that will be ran. Gocheck is mandatory for testing suites.")
(spacemacs|defc go-use-gocheck-for-testing nil
"If using gocheck for testing when running the tests -check.f will be used instead of -run to specify the test that will be ran. Gocheck is mandatory for testing suites."
'boolean nil #'booleanp)

(defvar go-use-testify-for-testing nil
"If using testify for testing when running the tests -testify.m will be used instead of -run to specify the test that will be ran. Testify is mandatory for testing suites.")
(spacemacs|defc go-use-testify-for-testing nil
"If using testify for testing when running the tests -testify.m will be used instead of -run to specify the test that will be ran. Testify is mandatory for testing suites."
'boolean nil #'booleanp)

(defvar go-format-before-save nil
"Use gofmt before save. Set to non-nil to enable gofmt before saving. Default is nil.")
(put 'go-format-before-save 'safe-local-variable #'symbolp)
(spacemacs|defc go-format-before-save nil
"Use gofmt before save. Set to non-nil to enable gofmt before saving. Default is nil."
'boolean nil #'booleanp)

(defvar go-tab-width 8
"Set the `tab-width' in Go mode. Default is 8.")
(spacemacs|defc go-tab-width 8
"Set the `tab-width' in Go mode. Default is 8."
'integer nil #'integerp)

(defvar go-use-golangci-lint nil
"Use `golangci-lint' if the variable has non-nil value.")
(spacemacs|defc go-use-golangci-lint nil
"Use `golangci-lint' if the variable has non-nil value."
'boolean nil #'booleanp)

(defvar go-test-buffer-name "*go test*"
"Name of the buffer for go test output. Default is *go test*.")
(spacemacs|defc go-test-buffer-name "*go test*"
"Name of the buffer for go test output. Default is *go test*."
'string nil #'stringp)

(defvar go-use-test-args ""
"Additional arguments to be supplied to `go test` during runtime.")
(spacemacs|defc go-use-test-args ""
"Additional arguments to be supplied to `go test` during runtime."
'string nil #'stringp)

(defvar go-test-verbose nil
"Control verbosity of `go test` output")
(spacemacs|defc go-test-verbose nil
"Control verbosity of `go test` output"
'boolean nil #'booleanp)

(defvar go-run-args ""
"Additional arguments to by supplied to `go run` during runtime.")
(spacemacs|defc go-run-args ""
"Additional arguments to by supplied to `go run` during runtime."
'string nil #'stringp)

(defvar go-run-command "go run"
"Go run command. Default is `go run`.")
(spacemacs|defc go-run-command "go run"
"Go run command. Default is `go run`."
'string nil #'stringp)

(defvar go-test-command "go test"
"Go test command. Default is `go test`.")
(spacemacs|defc go-test-command "go test"
"Go test command. Default is `go test`."
'string nil #'stringp)
14 changes: 6 additions & 8 deletions layers/+lang/go/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
(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)))
:init (add-hook 'go-mode-local-vars-hook 'spacemacs//go-enable-flycheck-golangci-lint)))

(defun go/post-init-ggtags ()
(add-hook 'go-mode-local-vars-hook #'spacemacs/ggtags-mode-enable))
Expand All @@ -81,7 +81,8 @@
(spacemacs/helm-gtags-define-keys-for-mode 'go-mode))

(defun go/init-go-eldoc ()
(use-package go-eldoc :defer t))
(use-package go-eldoc
:defer t))

(defun go/init-go-fill-struct ()
(use-package go-fill-struct
Expand Down Expand Up @@ -128,16 +129,13 @@

(defun go/init-go-mode ()
(use-package go-mode
:hook (go-mode . spacemacs//go-set-tab-width)
(go-mode-local-vars . spacemacs//go-setup-backend)
(go-mode-local-vars . spacemacs//go-setup-format)
:hook ((go-mode-local-vars . spacemacs//go-set-tab-width)
(go-mode-local-vars . spacemacs//go-setup-backend)
(go-mode-local-vars . spacemacs//go-setup-format))
:init
(progn
;; get go packages much faster
(setq go-packages-function 'spacemacs/go-packages-gopkgs)
(dolist (value '(lsp go-mode))
(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
Expand Down

0 comments on commit 247d059

Please sign in to comment.