Build go source on save
This commit is contained in:
parent
e79ef3428a
commit
9cbb7d0efd
1 changed files with 17 additions and 1 deletions
|
@ -116,7 +116,23 @@
|
|||
(use-package go-mode
|
||||
:config
|
||||
(add-hook 'before-save-hook #'gofmt-before-save)
|
||||
(add-hook 'go-mode-hook 'eglot-ensure))
|
||||
(add-hook 'go-mode-hook 'eglot-ensure)
|
||||
|
||||
(defun me/go-mode-compile-command-hook ()
|
||||
;; if no makefile use go build for compile command
|
||||
(unless (or (file-exists-p "makefile")
|
||||
(file-exists-p "Makefile"))
|
||||
(set (make-local-variable 'compile-command)
|
||||
(concat "go " "build " buffer-file-name))))
|
||||
|
||||
(add-hook 'go-mode-hook 'me/go-mode-compile-command-hook)
|
||||
|
||||
(defun me/go-mode-compile-on-save ()
|
||||
;; compile on save hook
|
||||
(make-local-variable 'after-save-hook)
|
||||
(add-hook 'after-save-hook (lambda () (compile compile-command))))
|
||||
|
||||
(add-hook 'go-mode-hook 'me/go-mode-compile-on-save))
|
||||
|
||||
(use-package rust-mode
|
||||
:hook (rust . eglot-ensure))
|
||||
|
|
Loading…
Add table
Reference in a new issue