From 11c479c1f0dd6f22ce8d5fe7ef5292e81a0bf42e Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Mon, 29 Jul 2019 08:30:32 -0700 Subject: [emacs] improve support for go move the requirement for `company-go` to the module for go. rework the configuration for hydra, to make it a little bit easier. force length of comments to 80 characters per line. --- emacs.d/custom/fcuny-company.el | 7 ----- emacs.d/custom/fcuny-go.el | 57 +++++++++++++++++++++++++++++------------ 2 files changed, 40 insertions(+), 24 deletions(-) diff --git a/emacs.d/custom/fcuny-company.el b/emacs.d/custom/fcuny-company.el index 4ffc900..0ea1fad 100644 --- a/emacs.d/custom/fcuny-company.el +++ b/emacs.d/custom/fcuny-company.el @@ -2,11 +2,4 @@ :ensure t :diminish company-mode) -(use-package company-go - :ensure t - :after (company) - :hook (go-mode . (lambda () - (setq-local company-backends - (append (list 'company-go) company-backends))))) - (provide 'fcuny-company) diff --git a/emacs.d/custom/fcuny-go.el b/emacs.d/custom/fcuny-go.el index cd0c05f..9cc72cf 100644 --- a/emacs.d/custom/fcuny-go.el +++ b/emacs.d/custom/fcuny-go.el @@ -1,57 +1,80 @@ (use-package go-mode :ensure t + :after (exec-path-from-shell flycheck flyspell company company-go hydra) + :hook ((go-mode . fcuny/go-mode-setup) (go-mode . company-mode)) - :bind (("C-c a ?" . godoc-at-point) - ("C-c a ." . godef-jump) - ("C-c a a" . go-import-add)) + :custom (godoc-use-completing-read t) (gofmt-command "goimports") + ;; see https://github.com/dominikh/go-mode.el/issues/262 (godoc-at-point-function 'godoc-gogetdoc) + :init (defun fcuny/go-mode-setup () (setq tab-width 4) + (setq comment-auto-fill-only-comments t) + (setq fill-column 80) + (auto-fill-mode 1) (add-hook 'before-save-hook 'gofmt-before-save)) + :config (when (memq window-system '(mac ns)) (exec-path-from-shell-copy-env "GOPATH")) - (defhydra go-hydra (:color teal :columns 3) - "Go" - ("r" go-guru-referrers "referrers") - ("i" go-guru-implements "implements") - ("d" go-guru-definition "definition") - ("D" go-guru-describe "describe") - ("t" go-test-current-test "run this test") - ("f" go-test-current-file "run tests for this file")) - (define-key go-mode-map (kbd "C-c g") 'go-hydra/body)) + + (defhydra hydra-go-menu (:columns 2) + " +^naviguation^ ^test^ +^-----------^ ^----^ +_r_: referrers _t_: run this test +_i_: implements _f_: test this file +_d_: definition +_D_: describe +" + ("r" go-guru-referrers) + ("i" go-guru-implements) + ("d" go-guru-definition) + ("D" go-guru-describe) + ("t" go-test-current-test) + ("f" go-test-current-file) + ("q" nil "quit" :color blue)) + + (define-key go-mode-map (kbd "C-c g") 'hydra-go-menu/body)) (use-package go-guru :ensure t :after go-mode + :commands (go-guru-describe go-guru-freevars go-guru-implements go-guru-peers go-guru-referrers go-guru-definition go-guru-pointsto go-guru-callstack go-guru-whicherrs go-guru-callers go-guru-callees go-guru-expand-region) + :config (unless (executable-find "guru") (warn "go-mode: couldn't find guru, refactoring commands won't work")) + (add-hook 'go-mode-hook #'go-guru-hl-identifier-mode)) (use-package go-eldoc :ensure t :after go-mode + :config (add-hook 'go-mode-hook 'go-eldoc-setup)) -(use-package godoctor - :ensure t - :after go-mode) +(use-package godoctor :ensure t :after go-mode) + +(use-package gotest :ensure t :after go-mode) -(use-package gotest +(use-package company-go :ensure t - :after go-mode) + :after (company) + :hook (go-mode . (lambda () + (setq-local company-backends + (append (list 'company-go) company-backends))))) (provide 'fcuny-go) -- cgit 1.4.1