summaryrefslogtreecommitdiff
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
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.
-rw-r--r--emacs.d/custom/fcuny-company.el12
-rw-r--r--emacs.d/custom/fcuny-go.el28
-rw-r--r--emacs.d/custom/fcuny-ui.el3
3 files changed, 36 insertions, 7 deletions
diff --git a/emacs.d/custom/fcuny-company.el b/emacs.d/custom/fcuny-company.el
new file mode 100644
index 0000000..4ffc900
--- /dev/null
+++ b/emacs.d/custom/fcuny-company.el
@@ -0,0 +1,12 @@
+(use-package company
+ :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 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)
diff --git a/emacs.d/custom/fcuny-ui.el b/emacs.d/custom/fcuny-ui.el
index e466a36..e5b9356 100644
--- a/emacs.d/custom/fcuny-ui.el
+++ b/emacs.d/custom/fcuny-ui.el
@@ -36,4 +36,7 @@
;; Adaptive cursor width shows width of character, e.g. TAB.
(setq x-stretch-cursor t)
+(use-package hydra
+ :ensure t)
+
(provide 'fcuny-ui)