Some of our comments/docs can come off as disparaging or snide. They're
glimpses of unfiltered frustration or snarky rubber ducking gone too
far, something I can totally sympathize with, as a scatterbrained
tinkerer, unwittingly made responsible for a lot of work that isn't mine
because of Doom's position as a middleman. But now that Doom has a
veritable userbase, I'd like to hold it to a higher standard.
Light-hearted banter and aired grievances in our source code,
documentation, or community are fine if focused on the problem or the
personal/shared experiences of the community (things that offer value or
amusement to others), but it is never acceptable to attack people or
their efforts. Especially not the very people on whose shoulders Doom
stands.
I sincerely apologize if these have offended you.
Amend:
|
||
---|---|---|
.. | ||
autoload | ||
config.el | ||
doctor.el | ||
packages.el | ||
README.org |
:lang python
Description unfold
This module adds Python support to Doom Emacs.
- Syntax checking (flycheck)
- Snippets
- Run tests (nose, pytest)
- Auto-format (with
black
, requires :editor format) - LSP integration (
mspyls
,pyls
, orpyright
)
Maintainers
Module flags
- +conda
- Enable python virtual environment support via Conda.
- +cython
- Enable support for Cython files support.
- +lsp
-
Enable LSP support for
python-mode
. Requires :tools lsp and a langserver (supports mspyls, pyls, and pyright). - +poetry
- Enable Python packaging, dependency management, and virtual environment support via Poetry.
- +pyenv
- Enable Python virtual environment support via pyenv
- +pyright
- Use the pyright LSP server instead of mspyls or pyls (requires +lsp).
- +tree-sitter
- Leverages tree-sitter for better syntax highlighting and structural text editing. Requires :tools tree-sitter.
Packages
Hacks
- anaconda-mode is configured to activate when lsp-mode (or eglot) don't – or fail to.
TODO Changelog
This module does not have a changelog yet.
Installation
Enable this module in your doom!
block.
This module has no hard requirements, but softly depends on:
-
For this module's supported test runners:
$ pip install pytest
$ pip install nose
- The :editor format module uses Black for python files:
$ pip install black
- pyimport requires Python's module
pyflakes
:$ pip install pyflakes
- py-isort requires isort to be installed:
pip install isort
-
Python virtual environments install instructions at:
cython
requires Cython
Language Server Protocol Support
For LSP support the :tools lsp module must be enabled, along with this module's +lsp flag. By default, it supports mspyls and pyls, in that order. With the +pyright flag, it will try Pyright first.
Each of these servers must be installed on your system via your OS package manager or manually:
- pyls can be installed with
$ pip install python-language-server[all]
. - mspyls can be installed by typing
M-x lsp-install-server RET mspyls
. - pyright can be installed with
$ pip install pyright
or$ npm i -g pyright
.
TODO Usage
🔨 This module's usage documentation is incomplete. Complete it?
This module supports LSP. It requires installation of Python Language Server, Microsoft Language Server, or pyright, see LSP Support.
To enable support for auto-formatting with black enable :editor format.
Keybindings
Binding | Description |
---|---|
<localleader> c c | Compile Cython buffer |
<localleader> i i | Insert mising imports |
<localleader> i r | Remove unused imports |
<localleader> i s | Sort imports |
<localleader> i o | Optimize imports |
<localleader> t r | nosetests-again |
<localleader> t a | nosetests-all |
<localleader> t s | nosetests-one |
<localleader> t v | nosetests-module |
<localleader> t A | nosetests-pdb-all |
<localleader> t O | nosetests-pdb-one |
<localleader> t V | nosetests-pdb-module |
<localleader> t f | python-pytest-file |
<localleader> t k | python-pytest-file-dwim |
<localleader> t t | python-pytest-function |
<localleader> t m | python-pytest-function-dwim |
<localleader> t r | python-pytest-repeat |
<localleader> t p | python-pytest-popup |
<localleader> g d | anaconda-mode-find-definitions |
<localleader> g h | anaconda-mode-show-doc |
<localleader> g a | anaconda-mode-find-assignments |
<localleader> g f | anaconda-mode-find-file |
<localleader> g u | anaconda-mode-find-references |
TODO Configuration
🔨 This module's configuration documentation is incomplete. Complete it?
This module has the following variables to set extra arguments to ipython and jupyter shells:
;; in $DOOMDIR/config.el
(setq +python-ipython-repl-args '("-i" "--simple-prompt" "--no-color-info"))
(setq +python-jupyter-repl-args '("--simple-prompt"))
Troubleshooting
There are no known problems with this module. Report one?
Frequently asked questions
This module has no FAQs yet. Ask one?
TODO Appendix
🔨 This module has no appendix yet. Write one?