Use apheleia instead of lsp-mode to autoformat buffers
This commit is contained in:
parent
9bbde40734
commit
dc833f1f01
2 changed files with 9 additions and 8 deletions
|
|
@ -188,17 +188,18 @@
|
||||||
(use-package iedit)
|
(use-package iedit)
|
||||||
(use-package wgrep)
|
(use-package wgrep)
|
||||||
|
|
||||||
(defun reformat-by-lsp ()
|
(use-package apheleia
|
||||||
"Reformat a file using LSP actions."
|
:config
|
||||||
(when (bound-and-true-p lsp-mode)
|
(apheleia-global-mode)
|
||||||
(progn
|
(setf (alist-get 'python-mode apheleia-mode-alist)
|
||||||
(lsp-organize-imports)
|
'(ruff-isort ruff))
|
||||||
(lsp-format-buffer))))
|
(setf (alist-get 'python-ts-mode apheleia-mode-alist)
|
||||||
|
'(ruff-isort ruff))
|
||||||
|
)
|
||||||
|
|
||||||
(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 . reformat-by-lsp)
|
|
||||||
:init
|
:init
|
||||||
(setq lsp-keymap-prefix "C-z l")
|
(setq lsp-keymap-prefix "C-z l")
|
||||||
:config
|
:config
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,7 @@ PIPX_PKGS=(
|
||||||
# keep-sorted start
|
# keep-sorted start
|
||||||
python-lsp-server
|
python-lsp-server
|
||||||
rshell
|
rshell
|
||||||
|
ruff
|
||||||
# keep-sorted end
|
# keep-sorted end
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -109,7 +110,6 @@ PYLSP_PLUGINS=(
|
||||||
pydantic
|
pydantic
|
||||||
pylsp-mypy
|
pylsp-mypy
|
||||||
pylsp-rope
|
pylsp-rope
|
||||||
python-lsp-ruff
|
|
||||||
types-pyxdg
|
types-pyxdg
|
||||||
# keep-sorted end
|
# keep-sorted end
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue