From c39ea4ff392d0ddd84873b7a978cc89086f695ba Mon Sep 17 00:00:00 2001 From: Ohad Livne Date: Wed, 4 Jun 2025 22:45:52 +0300 Subject: [PATCH] Rely on LSP to reformat Rust buffers --- .config/emacs/init.el | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) 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)