From ad117e053ac537d079797c330d84589f1e9f7412 Mon Sep 17 00:00:00 2001 From: Guangxiong Lin Date: Thu, 17 Mar 2022 23:27:03 +0800 Subject: Rearrange go env in emacs --- .emacs.d/lisp/init-eglot.el | 15 +++++++++++++++ .emacs.d/lisp/init-evil.el | 3 ++- .emacs.d/lisp/init-go.el | 13 +++++++++++++ .emacs.d/lisp/init-lang.el | 11 ----------- .emacs.d/lisp/init-misc.el | 3 +++ 5 files changed, 33 insertions(+), 12 deletions(-) create mode 100644 .emacs.d/lisp/init-eglot.el create mode 100644 .emacs.d/lisp/init-go.el (limited to '.emacs.d/lisp') 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) -- cgit v1.2.3