From 1d49cd7ed82a4060e74139137f8f864ce728131d Mon Sep 17 00:00:00 2001 From: Lupco Kotev Date: Thu, 7 Jun 2018 21:26:51 +0200 Subject: [PATCH] Add golangci-lint support --- layers/+lang/go/config.el | 3 +++ layers/+lang/go/funcs.el | 10 ++++++++++ layers/+lang/go/packages.el | 8 ++++++++ 3 files changed, 21 insertions(+) diff --git a/layers/+lang/go/config.el b/layers/+lang/go/config.el index 5bd39c1e3..c99886918 100644 --- a/layers/+lang/go/config.el +++ b/layers/+lang/go/config.el @@ -28,6 +28,9 @@ (defvar go-use-gometalinter nil "Use gometalinter if the variable has non-nil value.") +(defvar go-use-golangci-lint nil + "Use golangci-lint if the variable has non-nil value.") + (defvar go-test-buffer-name "*go test*" "Name of the buffer for go test output. Default is *go test*.") diff --git a/layers/+lang/go/funcs.el b/layers/+lang/go/funcs.el index d0779f6bf..f019634c1 100644 --- a/layers/+lang/go/funcs.el +++ b/layers/+lang/go/funcs.el @@ -64,6 +64,16 @@ go-errcheck)) (flycheck-gometalinter-setup)) +(defun spacemacs//go-enable-golangci-lint () + "Enable `flycheck-golangci-lint' and disable overlapping `flycheck' linters." + (setq flycheck-disabled-checkers '(go-gofmt + go-golint + go-vet + go-build + go-test + go-errcheck)) + (flycheck-golangci-lint-setup)) + (defun spacemacs/go-run-tests (args) (interactive) (compilation-start (concat "go test " args " " go-use-test-args) diff --git a/layers/+lang/go/packages.el b/layers/+lang/go/packages.el index ba26d6c54..a11fba526 100644 --- a/layers/+lang/go/packages.el +++ b/layers/+lang/go/packages.el @@ -18,6 +18,9 @@ (flycheck-gometalinter :toggle (and go-use-gometalinter (configuration-layer/package-used-p 'flycheck))) + (flycheck-golangci-lint :toggle (and go-use-golangci-lint + (configuration-layer/package-used-p + 'flycheck))) ggtags helm-gtags go-eldoc @@ -62,6 +65,11 @@ :defer t :init (add-hook 'go-mode-hook 'spacemacs//go-enable-gometalinter t))) +(defun go/init-flycheck-golangci-lint () + (use-package flycheck-golangci-lint + :defer t + :init (add-hook 'go-mode-hook 'spacemacs//go-enable-golangci-lint t))) + (defun go/post-init-ggtags () (add-hook 'go-mode-local-vars-hook #'spacemacs/ggtags-mode-enable))