diff --git a/.config/emacs/init.el b/.config/emacs/init.el index adafc3e..29c99d3 100644 --- a/.config/emacs/init.el +++ b/.config/emacs/init.el @@ -127,14 +127,17 @@ (use-package iedit) (use-package wgrep) +(defun reformat-by-lsp () + "Reformat a file using LSP actions." + (when (bound-and-true-p lsp-mode) + (progn + (lsp-organize-imports) + (lsp-format-buffer)))) + (use-package lsp-mode :bind (:map lsp-mode-map ("M-?" . lsp-find-references)) - :hook (before-save . (lambda () - (when (bound-and-true-p lsp-mode) - (progn - (lsp-organize-imports) - (lsp-format-buffer))))) + :hook (before-save . reformat-by-lsp) :init (setq lsp-keymap-prefix "C-z l") :custom @@ -217,6 +220,4 @@ When DEBUG is set, run the test in the debugger." :config (direnv-mode)) -(use-package rustic - :custom - (rustic-format-on-save t)) +(use-package rustic)