Rely on LSP to reformat Rust buffers

This commit is contained in:
Ohad Livne 2025-06-04 22:45:52 +03:00
parent 2f003402d3
commit c39ea4ff39
Signed by: libohad-dev
GPG key ID: 34FDC68B51191A4D

View file

@ -127,14 +127,17 @@
(use-package iedit) (use-package iedit)
(use-package wgrep) (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 (use-package lsp-mode
:bind (:map lsp-mode-map :bind (:map lsp-mode-map
("M-?" . lsp-find-references)) ("M-?" . lsp-find-references))
:hook (before-save . (lambda () :hook (before-save . reformat-by-lsp)
(when (bound-and-true-p lsp-mode)
(progn
(lsp-organize-imports)
(lsp-format-buffer)))))
:init :init
(setq lsp-keymap-prefix "C-z l") (setq lsp-keymap-prefix "C-z l")
:custom :custom
@ -217,6 +220,4 @@ When DEBUG is set, run the test in the debugger."
:config :config
(direnv-mode)) (direnv-mode))
(use-package rustic (use-package rustic)
:custom
(rustic-format-on-save t))