Chapter 26. Configure Emacs
Note
In this configuration, we use two virtual enviromnents. The one we are creating in this chapter is semi-permanent; it's for emacs. We'll make another one for the project. Note that this may make it harder to run code directly from emacs, but since this approach doesn't do that (yet), that's a future problem.
-
Create the editor's virtual environment
python -m venv ~/.config/venv/emacs_python_ide
source ~/.config/venv/emacs_python_ide/bin/activate
-
Install IDE python software
pip install python-lsp-server pylsp-mypy python-lsp-isort python-lsp-black pylsp-rope python-lsp-ruff
-
Install Treesit prerequisites in emacs
-
Set up editor project defaults
-
Install tree-sitter python
from 2024-11 Habamax https://gist.github.com/habamax/290cda0e0cdc6118eb9a06121b9bc0d7)
-
Verify treesit setup
M-x ielm
(treesit-language-available-p 'python)
It should return
t
.Open python file and activate treesitter mode with
M-x python-ts-mode RET
-
One-time setup?
maybe set treesit-font-lock-level to 4