aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuangxiong Lin <[email protected]>2022-03-17 23:27:03 +0800
committerGuangxiong Lin <[email protected]>2022-03-17 23:27:03 +0800
commitad117e053ac537d079797c330d84589f1e9f7412 (patch)
tree2c4ec2022c4cbc5ee9417f2ef70573f9c20d108d
parent919fbc2561a19c676f759f328f43713968cfd25b (diff)
downloaddotfiles-ad117e053ac537d079797c330d84589f1e9f7412.tar.gz
dotfiles-ad117e053ac537d079797c330d84589f1e9f7412.tar.bz2
dotfiles-ad117e053ac537d079797c330d84589f1e9f7412.zip
Rearrange go env in emacs
-rw-r--r--.emacs.d/init.el2
-rw-r--r--.emacs.d/lisp/init-eglot.el15
-rw-r--r--.emacs.d/lisp/init-evil.el3
-rw-r--r--.emacs.d/lisp/init-go.el13
-rw-r--r--.emacs.d/lisp/init-lang.el11
-rw-r--r--.emacs.d/lisp/init-misc.el3
6 files changed, 35 insertions, 12 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el
index e711f30..11567b0 100644
--- a/.emacs.d/init.el
+++ b/.emacs.d/init.el
@@ -25,6 +25,8 @@
(require 'init-flycheck)
(require 'init-org)
(require 'init-lang)
+(require 'init-go)
+(require 'init-eglot)
(require 'init-filetype)
(require 'init-deft)
(require 'init-input-method)
diff --git a/.emacs.d/lisp/init-eglot.el b/.emacs.d/lisp/init-eglot.el
new file mode 100644
index 0000000..58b4d02
--- /dev/null
+++ b/.emacs.d/lisp/init-eglot.el
@@ -0,0 +1,15 @@
+(defun gx/eglot-format-before-save ()
+ (add-hook 'before-save-hook #'eglot-format nil t))
+
+(defun gx/eglot-code-action-organize-imports-before-save ()
+ (add-hook 'before-save-hook #'eglot-code-action-organize-imports nil t))
+
+(with-eval-after-load 'evil
+ (evil-define-key 'normal 'eglot--managed-mode
+ (kbd "gd") 'xref-find-definitions
+ (kbd "gr") 'xref-find-references
+ (kbd "K") 'eldoc-doc-buffer
+ (kbd "gi") 'eglot-find-implementation
+ (kbd "C-t") 'xref-pop-marker-stack))
+
+(provide 'init-eglot)
diff --git a/.emacs.d/lisp/init-evil.el b/.emacs.d/lisp/init-evil.el
index 4e5550f..efbc645 100644
--- a/.emacs.d/lisp/init-evil.el
+++ b/.emacs.d/lisp/init-evil.el
@@ -26,7 +26,8 @@
;; evil-collection
(when (gx/maybe-require-package 'evil-collection)
(with-eval-after-load 'evil
- (evil-collection-init)))
+ (evil-collection-init
+ 'xref)))
(with-eval-after-load 'evil-collection-unimpaired
(gx/diminish 'evil-collection-unimpaired-mode))
diff --git a/.emacs.d/lisp/init-go.el b/.emacs.d/lisp/init-go.el
new file mode 100644
index 0000000..f0a6b84
--- /dev/null
+++ b/.emacs.d/lisp/init-go.el
@@ -0,0 +1,13 @@
+(when (gx/maybe-require-package 'go-mode)
+ (add-to-list 'auto-mode-alist '("\\.go\\'" . go-mode)))
+
+(add-hook 'go-mode-hook (lambda () (setq tab-width 4)))
+
+(gx/maybe-require-package 'go-dlv)
+
+(when (gx/maybe-require-package 'eglot)
+ (add-hook 'go-mode-hook #'eglot-ensure)
+ (add-hook 'go-mode-hook #'gx/eglot-format-before-save)
+ (add-hook 'go-mode-hook #'gx/eglot-code-action-organize-imports-before-save))
+
+(provide 'init-go)
diff --git a/.emacs.d/lisp/init-lang.el b/.emacs.d/lisp/init-lang.el
index 2d818a4..b96fd92 100644
--- a/.emacs.d/lisp/init-lang.el
+++ b/.emacs.d/lisp/init-lang.el
@@ -3,15 +3,6 @@
(with-eval-after-load 'ledger-mode
(setq ledger-default-date-format ledger-iso-date-format))
-(when (gx/maybe-require-package 'go-mode)
- (add-to-list 'auto-mode-alist '("\\.go\\'" . go-mode))
- (add-hook 'go-mode-hook (lambda () (setq tab-width 4))))
-
-(gx/maybe-require-package 'go-dlv)
-
-(when (gx/maybe-require-package 'eglot)
- (add-hook 'go-mode-hook 'eglot-ensure))
-
(gx/maybe-require-package 'realgud)
(setq plantuml-jar-path "~/.local/bin/plantuml.jar"
@@ -25,6 +16,4 @@
(with-eval-after-load 'org
(add-to-list 'org-src-lang-modes '("plantuml" . plantuml))))
-(gx/diminish 'eldoc-mode)
-
(provide 'init-lang)
diff --git a/.emacs.d/lisp/init-misc.el b/.emacs.d/lisp/init-misc.el
index b4239c9..579ac8b 100644
--- a/.emacs.d/lisp/init-misc.el
+++ b/.emacs.d/lisp/init-misc.el
@@ -61,4 +61,7 @@
(with-eval-after-load 'undo-tree
(gx/diminish 'undo-tree-mode))
+(with-eval-after-load 'eldoc
+ (gx/diminish 'eldoc-mode))
+
(provide 'init-misc)