From cb45cd7b4b3a4bb9682616987a8d7097e228f2da Mon Sep 17 00:00:00 2001 From: Ohad Livne Date: Wed, 4 Jun 2025 22:45:47 +0300 Subject: [PATCH] Use the LSP server to reformat code --- .config/emacs/init.el | 17 +++++------------ .config/setup/01-install-packages.sh | 4 +++- .local/bin/init-venv | 8 +------- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/.config/emacs/init.el b/.config/emacs/init.el index ecb3810..0f882ea 100644 --- a/.config/emacs/init.el +++ b/.config/emacs/init.el @@ -128,6 +128,11 @@ (use-package wgrep) (use-package lsp-mode + :hook (before-save . (lambda () + (when (bound-and-true-p lsp-mode) + (progn + (lsp-organize-imports) + (lsp-format-buffer))))) :init (setq lsp-keymap-prefix "C-z l") :custom @@ -190,18 +195,6 @@ ("C-M-t" . recompile)) :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 (use-package ein :bind (("C-z j" . ein:run) diff --git a/.config/setup/01-install-packages.sh b/.config/setup/01-install-packages.sh index 87eae49..793fd4d 100755 --- a/.config/setup/01-install-packages.sh +++ b/.config/setup/01-install-packages.sh @@ -33,7 +33,9 @@ postfix \ pulseaudio \ pulseaudio-utils \ python3-poetry \ -python3-pylsp \ +python3-pylsp-black \ +python3-pylsp-isort \ +python3-pylsp-rope \ python3.12-venv \ qtwayland5 \ slurp \ diff --git a/.local/bin/init-venv b/.local/bin/init-venv index 5c72b71..ca07575 100755 --- a/.local/bin/init-venv +++ b/.local/bin/init-venv @@ -1,9 +1,3 @@ #! /usr/bin/sh -poetry add \ - --group dev \ - black \ - isort -poetry add \ - --group test \ - coverage +poetry add --group dev coverage