summary refs log tree commit diff
path: root/emacs.d/custom/fcuny-go.el
diff options
context:
space:
mode:
authorFranck Cuny <fcuny@twitter.com>2019-07-26 09:37:00 -0700
committerFranck Cuny <fcuny@twitter.com>2019-07-26 09:37:00 -0700
commita1644b85424e383490a6eda084a51b9028b2c2a3 (patch)
tree944a9d5a8d57fb83a02dd8b272a8f77fdaf3e3f1 /emacs.d/custom/fcuny-go.el
parent[git] some clean up (diff)
downloademacs.d-a1644b85424e383490a6eda084a51b9028b2c2a3.tar.gz
[emacs] improve support for go-mode
improve the support to write go code.  adding hydra to don't have to
remember all the commands i want to use with `go-guru`, and add
`gotest` to run tests directly from emacs.

add `company-go` for code completion.

will likely add more commands to hydra as i go.
Diffstat (limited to '')
-rw-r--r--emacs.d/custom/fcuny-go.el28
1 files changed, 21 insertions, 7 deletions
diff --git a/emacs.d/custom/fcuny-go.el b/emacs.d/custom/fcuny-go.el
index 75bd042..cd0c05f 100644
--- a/emacs.d/custom/fcuny-go.el
+++ b/emacs.d/custom/fcuny-go.el
@@ -1,13 +1,14 @@
 (use-package go-mode
   :ensure t
-  :after (exec-path-from-shell flycheck flyspell)
-  :hook (go-mode . fcuny/go-mode-setup)
-  :bind (("M-?" . godoc-at-point)
-         ("M-." . godef-jump)
-         ;; Jump back after godef-jump
-         ("M-*" . pop-tag-mark))
+  :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
@@ -16,7 +17,16 @@
     (add-hook 'before-save-hook 'gofmt-before-save))
   :config
   (when (memq window-system '(mac ns))
-    (exec-path-from-shell-copy-env "GOPATH")))
+    (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))
 
 (use-package go-guru
   :ensure t
@@ -40,4 +50,8 @@
   :ensure t
   :after go-mode)
 
+(use-package gotest
+  :ensure t
+  :after go-mode)
+
 (provide 'fcuny-go)