Use the LSP server to reformat code

This commit is contained in:
Ohad Livne 2025-06-04 22:45:47 +03:00
parent ca4600f0a0
commit cb45cd7b4b
Signed by: libohad-dev
GPG key ID: 34FDC68B51191A4D
3 changed files with 9 additions and 20 deletions

View file

@ -128,6 +128,11 @@
(use-package wgrep) (use-package wgrep)
(use-package lsp-mode (use-package lsp-mode
:hook (before-save . (lambda ()
(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
@ -190,18 +195,6 @@
("C-M-t" . recompile)) ("C-M-t" . recompile))
:hook (python-mode . load-python-env)) :hook (python-mode . load-python-env))
; Requires the Python package "black"
(use-package blacken
:hook (python-mode . blacken-mode))
; Requires the Python package "isort"
(use-package py-isort
:hook (before-save . (lambda ()
(when (bound-and-true-p blacken-mode)
(py-isort-before-save))))
:config
(setq py-isort-options '("--profile" "black")))
;; Jupyter notebook integration ;; Jupyter notebook integration
(use-package ein (use-package ein
:bind (("C-z j" . ein:run) :bind (("C-z j" . ein:run)

View file

@ -33,7 +33,9 @@ postfix \
pulseaudio \ pulseaudio \
pulseaudio-utils \ pulseaudio-utils \
python3-poetry \ python3-poetry \
python3-pylsp \ python3-pylsp-black \
python3-pylsp-isort \
python3-pylsp-rope \
python3.12-venv \ python3.12-venv \
qtwayland5 \ qtwayland5 \
slurp \ slurp \

View file

@ -1,9 +1,3 @@
#! /usr/bin/sh #! /usr/bin/sh
poetry add \ poetry add --group dev coverage
--group dev \
black \
isort
poetry add \
--group test \
coverage