Commit 5266b54ec92e

Vincent Demeester <vincent@sbr.pm>
2018-03-21 14:16:51
Update go configuration
Add a hydra to test and fix the before-save-hook. Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent 3acfb77
Changed files (1)
lisp/vde-go.el
@@ -2,13 +2,31 @@
   :ensure t
   :mode "\\.go$"
   :interpreter "go"
+  :bind (:map go-mode-map
+	      ("C-," . 'hydra-go/body))
   :pin melpa
+  :init
+  (defhydra hydra-go (:hint nil :color teal)
+    "
+         ^Command^      ^Imports^       ^Doc^
+         ^-------^      ^-------^       ^---^
+      _r_: run      _ig_: goto       _d_: doc at point
+    [_g_]: guru     _ia_: add
+    ^  ^            _ir_: remove
+    "
+    ("g" 'hydra-go-guru/body :color blue)
+    ("r" go-run-main)
+    ("d" godoc-at-point)
+    ("ig" go-goto-imports )
+    ("ia" go-import-add)
+    ("ir" go-remove-unused-imports)
+    ("q" nil "quit" :color blue))
   :config
   
   (setq gofmt-command "goimports")
   (if (not (executable-find "goimports"))
       (warn "go-mode: couldn't find goimports; no code formatting/fixed imports on save")
-    (add-hook 'go-mode-hook (add-hook 'before-save-hook #'gofmt-before-save nil t))))
+    (add-hook 'before-save-hook 'gofmt-before-save)))
 
 (use-package go-guru
   :ensure t