go-mode cleanup

This commit is contained in:
Ivan Malison 2016-05-12 14:36:31 -07:00
parent 8c949d3c6d
commit b947ae9e69

View File

@ -2327,6 +2327,9 @@ window is active in the perspective."
:mode (("\\.go\\'" . go-mode)) :mode (("\\.go\\'" . go-mode))
:preface :preface
(progn (progn
(defun go-mode-glide-novendor ()
(projectile-with-default-dir (projectile-project-root)
(shell-command-to-string "glide novendor")))
(defun go-mode-create-imenu-index () (defun go-mode-create-imenu-index ()
"Create and return an imenu index alist. Unlike the default "Create and return an imenu index alist. Unlike the default
alist created by go-mode, this method creates an alist where alist created by go-mode, this method creates an alist where
@ -2361,7 +2364,7 @@ items follow a style that is consistent with other prog-modes."
(imalison:let-advise-around imalison:advise-normal-go-command (go-command "go")) (imalison:let-advise-around imalison:advise-normal-go-command (go-command "go"))
(defun imalison:go-mode-hook () (defun imalison:go-mode-hook ()
(go-eldoc-setup) (go-eldoc-setup)
(bind-key "C-c t" 'imalison:gotest go-mode-map) (bind-key go-mode-map)
(setq imenu-create-index-function (setq imenu-create-index-function
(lambda () (lambda ()
(imalison:flatten-imenu-index (imalison:flatten-imenu-index
@ -2369,29 +2372,49 @@ items follow a style that is consistent with other prog-modes."
(set (make-local-variable 'company-backends) '(company-go)))) (set (make-local-variable 'company-backends) '(company-go))))
:config :config
(progn (progn
(advice-add 'go-guru-definition :around 'imalison:advise-normal-go-command) (use-package gotest
(advice-add 'go-guru-definition :before :bind (:map go-mode-map
(lambda () ("C-c t" . 'imalison:gotest))
(with-no-warnings :preface
(ring-insert find-tag-marker-ring (point-marker))))) (progn
(advice-add 'go-import-add :around 'imalison:advise-normal-go-command) (imalison:prefix-alternatives
imalison:gotest go-test-current-test go-test-current-file))
:config
(progn
(setq go-test-verbose t)))
(use-package company-go (use-package company-go
:config (setq company-go-show-annotation t)) :config (setq company-go-show-annotation t))
(use-package go-projectile) (use-package go-projectile :demand t)
(use-package go-eldoc) (use-package go-eldoc :demand t)
(use-package gotest :demand t)
(load-file (imalison:join-paths (go-mode-get-go-path) "src"
"golang.org" "x" "tools" "cmd"
"guru" "go-guru.el"))
(use-package go-guru (use-package go-guru
:ensure nil) :bind (:map go-mode-map
(setq go-test-verbose t) ("M-." . go-guru-definition)
(bind-key "M-." 'go-guru-definition go-mode-map) ("M-," . pop-tag-mark))
(bind-key "M-," 'pop-tag-mark go-mode-map) :preface
(imalison:prefix-alternatives (progn
imalison:gotest go-test-current-test go-test-current-file) (defun imalison:set-go-guru-scope ()
(add-hook 'go-mode-hook 'imalison:go-mode-hook) (setq go-guru-scope (go-mode-parse-glide-novendor)))
(defun go-mode-parse-glide-novendor ()
(s-join ","
(cl-loop for path in (s-split "\n" (go-mode-glide-novendor))
collect (if (string-equal path ".")
(go-mode-workspace-path)
(s-replace "\./" (go-mode-workspace-path) path))))))
:config
(progn
(advice-add 'go-guru--set-scope-if-empty :before 'imalison:set-go-guru-scope)
(advice-add 'go-guru-start :before 'imalison:set-go-guru-scope)
(advice-add 'go-guru-definition :around 'imalison:advise-normal-go-command)
(advice-add 'go-guru-definition :before
(lambda ()
(with-no-warnings
(ring-insert find-tag-marker-ring (point-marker)))))))
(advice-add 'go-import-add :around 'imalison:advise-normal-go-command)
(setq gofmt-command "goimports") (setq gofmt-command "goimports")
(add-hook 'go-mode-hook 'imalison:go-mode-hook)
(add-hook 'before-save-hook 'gofmt-before-save t) (add-hook 'before-save-hook 'gofmt-before-save t)
(add-hook 'after-save-hook 'go-mode-install-current-project))) (add-hook 'after-save-hook 'go-mode-install-current-project)))