From cbe96e0440018651c74d46c270857b6af54bf10a Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Sat, 14 Nov 2015 00:19:10 -0800 Subject: [PATCH] gomode install current project on save --- dotfiles/emacs.d/init.el | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/dotfiles/emacs.d/init.el b/dotfiles/emacs.d/init.el index 3615b1e3..fafa33e5 100644 --- a/dotfiles/emacs.d/init.el +++ b/dotfiles/emacs.d/init.el @@ -2258,7 +2258,16 @@ items follow a style that is consistent with other prog-modes." (set (make-local-variable 'company-backends) '(company-go))) (add-hook 'go-mode-hook 'imalison:go-mode-hook) (setq gofmt-command "goimports") - (add-hook 'before-save-hook 'gofmt-before-save t))) + (add-hook 'before-save-hook 'gofmt-before-save t) + (defun go-mode-workspace-path () + (file-relative-name (projectile-project-root) + (concat (file-name-as-directory (or (getenv "GOPATH") "~/go")) "src"))) + (defun go-mode-install-current-project () + (interactive) + (start-process "go install" "go install log" "go" "install" + (concat (file-name-as-directory (go-mode-workspace-path)) + "..."))) + (add-hook 'before-save-hook 'go-mode-install-current-project))) (use-package rust-mode :mode (("\\.rs\\'" . rust-mode)))