summaryrefslogtreecommitdiff
path: root/emacs
diff options
context:
space:
mode:
Diffstat (limited to 'emacs')
-rw-r--r--emacs/functions.el4
-rw-r--r--emacs/init.el7
-rw-r--r--emacs/package-list.el1
3 files changed, 10 insertions, 2 deletions
diff --git a/emacs/functions.el b/emacs/functions.el
index 11db1ee..d23e412 100644
--- a/emacs/functions.el
+++ b/emacs/functions.el
@@ -90,6 +90,10 @@ enabled."
(float-time (time-subtract after-init-time before-init-time))
gcs-done))
+(defun my/eglot-organize-imports ()
+ "Interactively call ‘eglot-code-action-organize-imports’."
+ (call-interactively #'eglot-code-action-organize-imports))
+
(defmacro my/with-add-hook (hook &rest body)
(declare (indent 1) (debug t))
`(add-hook ,hook #'(lambda () ,@body)))
diff --git a/emacs/init.el b/emacs/init.el
index 9c5f5c7..741c6f8 100644
--- a/emacs/init.el
+++ b/emacs/init.el
@@ -145,8 +145,11 @@
(my/with-add-hook 'go-mode-hook
(setq tab-width 2)
- (add-hook 'before-save-hook #'gofmt-before-save nil :local)
- (flycheck-mode))
+
+ (when (executable-find "gopls")
+ (eglot-ensure)
+ (add-hook 'before-save-hook #'my/eglot-organize-imports nil :local)
+ (add-hook 'before-save-hook #'eglot-format-buffer nil :local)))
;; Flycheck
diff --git a/emacs/package-list.el b/emacs/package-list.el
index f7df4ba..6b049e2 100644
--- a/emacs/package-list.el
+++ b/emacs/package-list.el
@@ -3,6 +3,7 @@
counsel
diminish
dockerfile-mode
+ eglot
flycheck
go-mode
google-c-style