Automatically format Python files
This commit is contained in:
parent
01532fbac6
commit
265541d135
2 changed files with 17 additions and 1 deletions
|
|
@ -168,6 +168,18 @@
|
||||||
("C-c C-l" . nil))
|
("C-c C-l" . nil))
|
||||||
: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)
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,9 @@
|
||||||
|
|
||||||
python3 -m venv .venv
|
python3 -m venv .venv
|
||||||
. .venv/bin/activate
|
. .venv/bin/activate
|
||||||
pip install 'python-lsp-server[rope]' python-lsp-ruff
|
pip install \
|
||||||
|
black \
|
||||||
|
isort \
|
||||||
|
'python-lsp-server[rope]' \
|
||||||
|
python-lsp-ruff
|
||||||
pip install -e .
|
pip install -e .
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue