This repository provides a template for setting up a Python development environment in Emacs, leveraging poetry, nix, and Emacs' python-mode with lsp (Language Server Protocol) integration. This setup aims to streamline the development process and ensure consistent environments across different setups.
-
Emacs Configuration: Includes a
.dir-locals.elfile to automatically configure Emacspython-modeandlspfor use withpoetry. This ensures that the python interpreter and language servers (likesemgrepandpyls) are correctly pointed to the virtual environment created bypoetry. -
Poetry Environment: A sample
pyproject.tomlis provided which includes necessary Python language servers and other common dependencies for Python development. -
Nix Development Environment: A
devenv.nixfile is included to manage system libraries and environment variables specific to the project. This aids in creating a reproducible development environment. -
Local Customization: Users can create a
.envrc.localfile for customizing the development environment locally. This file is ignored by version control, allowing for individual preferences without affecting the main project setup.
- Run
wakecommand to install project dependencies.
- Ensure Emacs is installed with
python-modeandlsp-mode. - Place the
.dir-locals.elfile in the root of your project directory. - Open a Python file within the project, and Emacs will automatically configure the Python environment and LSP settings based on
poetry.
- Install
nixif not already installed. - Run
nix-shell devenv.nixto enter the development environment managed by Nix. This will set up all required system libraries and environment variables.
- Create a
.envrc.localfile at the root of your project to override or augment the settings in the.envrcfile. - This file should be used for settings that are specific to your local development environment and should not be committed to version control.
Contributions to improve this template are welcome. Please submit issues and pull requests with your suggestions and improvements.
Enjoy a seamless Python development experience in Emacs with emacs-python-nix-template!