Rely on LSP to reformat Rust buffers
This commit is contained in:
parent
2f003402d3
commit
c39ea4ff39
1 changed files with 9 additions and 8 deletions
|
|
@ -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))
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue