summary refs log tree commit diff
diff options
context:
space:
mode:
authorFranck Cuny <franck.cuny@gmail.com>2017-01-27 14:56:30 -0800
committerFranck Cuny <franck.cuny@gmail.com>2017-01-27 14:56:30 -0800
commitf6d8d8d6ffaf7d3b1d412f8a87a44ec27e15bff8 (patch)
tree5d369d3e921b065b56bd1c07028029c58a3b7c56
parent[Emacs] Install company (and support for go). (diff)
downloademacs.d-f6d8d8d6ffaf7d3b1d412f8a87a44ec27e15bff8.tar.gz
[Emacs] Improve support for Golang.
Install a few extra packages (go-guru, gotest); rewrite the hooks into
a function; don't display tabs with withespace mode.
-rw-r--r--emacs.d/init.el44
1 files changed, 25 insertions, 19 deletions
diff --git a/emacs.d/init.el b/emacs.d/init.el
index d44a982..0408dd6 100644
--- a/emacs.d/init.el
+++ b/emacs.d/init.el
@@ -230,26 +230,32 @@
   :ensure t
 
   :config
-   (when (memq window-system '(mac ns x))
-    (dolist (var '("GOPATH"))
-      (unless (getenv var)
-        (exec-path-from-shell-copy-env var))))
-   (use-package go-eldoc
-     :ensure t
-     :config
-     (add-hook 'go-mode-hook 'go-eldoc-setup))
-   (use-package gotest
-     :ensure t)
-   (add-hook 'before-save-hook 'gofmt-before-save)
-   (add-hook 'go-mode-hook (lambda () (setq-local tab-width 4))))
-
-(use-package hl-line
-  ;; highlight current line
-  :defer t
-  :init
   (progn
-    (add-hook 'text-mode-hook 'hl-line-mode)
-    (add-hook 'prog-mode-hook 'hl-line-mode)))
+    (when (memq window-system '(mac ns x))
+      (dolist (var '("GOPATH"))
+        (unless (getenv var)
+          (exec-path-from-shell-copy-env var))))
+
+    (use-package go-eldoc
+      :ensure t
+      :config
+      (add-hook 'go-mode-hook 'go-eldoc-setup))
+
+    (use-package gotest
+      :ensure t)
+
+    (use-package go-guru
+      :ensure t)
+
+    (defun fc/my-go-hook ()
+      (set (make-local-variable 'compile-command)
+           "go build -v && go test -v && go vet")
+      (setq-local tab-width 4)
+      (make-variable-buffer-local 'whitespace-style)
+      (setq whitespace-style (delq 'tabs whitespace-style)))
+
+    (add-hook 'before-save-hook 'gofmt-before-save)
+    (add-hook 'go-mode-hook 'fc/my-go-hook)))
 
 (use-package ibuffer
   ;; configuration for ibuffer