Use apheleia instead of lsp-mode to autoformat buffers

This commit is contained in:
Ohad Livne 2025-06-04 22:47:10 +03:00
parent 9bbde40734
commit dc833f1f01
Signed by: libohad-dev
GPG key ID: 34FDC68B51191A4D
2 changed files with 9 additions and 8 deletions

View file

@ -188,17 +188,18 @@
(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 apheleia
:config
(apheleia-global-mode)
(setf (alist-get 'python-mode apheleia-mode-alist)
'(ruff-isort ruff))
(setf (alist-get 'python-ts-mode apheleia-mode-alist)
'(ruff-isort ruff))
)
(use-package lsp-mode
:bind (:map lsp-mode-map
("M-?" . lsp-find-references))
:hook (before-save . reformat-by-lsp)
:init
(setq lsp-keymap-prefix "C-z l")
:config

View file

@ -93,6 +93,7 @@ PIPX_PKGS=(
# keep-sorted start
python-lsp-server
rshell
ruff
# keep-sorted end
)
@ -109,7 +110,6 @@ PYLSP_PLUGINS=(
pydantic
pylsp-mypy
pylsp-rope
python-lsp-ruff
types-pyxdg
# keep-sorted end
)