summary refs log tree commit diff
path: root/emacs/custom/my-lang-go.el
diff options
context:
space:
mode:
Diffstat (limited to 'emacs/custom/my-lang-go.el')
-rw-r--r--emacs/custom/my-lang-go.el30
1 files changed, 30 insertions, 0 deletions
diff --git a/emacs/custom/my-lang-go.el b/emacs/custom/my-lang-go.el
new file mode 100644
index 0000000..aa9f43b
--- /dev/null
+++ b/emacs/custom/my-lang-go.el
@@ -0,0 +1,30 @@
+;;; my-lang-go.el --- configure emacs for go -*- lexical-binding: t -*-
+;; Author: Franck Cuny <franck@fcuny.net>
+
+;;; Commentary:
+
+;;; Code:
+
+(require 'go-mode)
+(require 'gotest)
+(require 'lsp-mode)
+
+(add-hook 'go-mode-hook #'lsp-deferred)
+
+(defun my/lsp-go-install-save-hooks ()
+  "Set up before-save hooks to format buffer and add/delete imports."
+  (add-hook 'before-save-hook #'lsp-format-buffer t t)
+  (add-hook 'before-save-hook #'lsp-organize-imports t t))
+
+(defun my/go-mode-setup ()
+  "Hooks for `go-mode'."
+  (setq tab-width 4)
+  (setq go-test-verbose t))
+
+(add-hook 'go-mode-hook #'my/lsp-go-install-save-hooks)
+(add-hook 'go-mode-hook #'my/go-mode-setup)
+(add-hook 'go-mode-hook #'yas-minor-mode)
+
+(provide 'my-lang-go)
+
+;;; my-lang-go.el ends here