summary refs log tree commit diff
path: root/emacs
diff options
context:
space:
mode:
Diffstat (limited to 'emacs')
-rw-r--r--emacs/custom/my-lang-go.el30
-rw-r--r--emacs/init.el1
2 files changed, 31 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
diff --git a/emacs/init.el b/emacs/init.el
index 2dcca81..7db5aab 100644
--- a/emacs/init.el
+++ b/emacs/init.el
@@ -51,6 +51,7 @@
 (require 'my-elfeed)
 
 (require 'my-lsp)
+(require 'my-lang-go)
 (require 'my-lang-python)
 
 (require 'my-buffers)