Skip to content

Latest commit

 

History

History
155 lines (134 loc) · 6.66 KB

README.org

File metadata and controls

155 lines (134 loc) · 6.66 KB

:lang python

Description

This module adds Python support to Doom Emacs.

  • Syntax checking (doom-package:flycheck)
  • Snippets
  • Run tests (doom-package:nose, doom-package:pytest)
  • Auto-format (with black, requires doom-module::editor format)
  • LSP integration (mspyls, pyls, or pyright)

Maintainers

  • @hlissner

Become a maintainer?

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 doom-module::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 doom-module:+lsp).
+tree-sitter
Leverages tree-sitter for better syntax highlighting and structural text editing. Requires doom-module::tools tree-sitter.

Packages

  • doom-package:anaconda-mode
  • doom-package:conda
  • doom-package:nose
  • doom-package:pipenv
  • doom-package:pip-requirements
  • doom-package:poetry if doom-module:+poetry
  • doom-package:pyenv
  • doom-package:pyimport
  • doom-package:py-isort
  • doom-package:python-pytest
  • if doom-module:+cython
    • doom-package:cython-mode
    • doom-package:flycheck-cython if doom-module::checkers syntax
  • if doom-module:+lsp
    • if doom-module:+pyright
      • doom-package:lsp-pyright
    • else
      • doom-package:lsp-python-ms

Hacks

  • doom-package:anaconda-mode is configured to activate when doom-package:lsp-mode (or doom-package:eglot) don’t – or fail to.

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 doom-module::editor format module uses Black for python files: $ pip install black
  • doom-package:pyimport requires Python’s module pyflakes: $ pip install pyflakes
  • doom-package: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 doom-module::tools lsp module must be enabled, along with this module’s doom-module:+lsp flag. By default, it supports doom-package:mspyls and doom-package:pyls, in that order. With the doom-module:+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.

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 doom-module::editor format.

Keybindings

BindingDescription
<localleader> c cCompile Cython buffer
<localleader> i iInsert mising imports
<localleader> i rRemove unused imports
<localleader> i sSort imports
<localleader> i oOptimize imports
<localleader> t rnosetests-again
<localleader> t anosetests-all
<localleader> t snosetests-one
<localleader> t vnosetests-module
<localleader> t Anosetests-pdb-all
<localleader> t Onosetests-pdb-one
<localleader> t Vnosetests-pdb-module
<localleader> t fpython-pytest-file
<localleader> t kpython-pytest-file-dwim
<localleader> t tpython-pytest-function
<localleader> t mpython-pytest-function-dwim
<localleader> t rpython-pytest-repeat
<localleader> t ppython-pytest-popup
<localleader> g danaconda-mode-find-definitions
<localleader> g hanaconda-mode-show-doc
<localleader> g aanaconda-mode-find-assignments
<localleader> g fanaconda-mode-find-file
<localleader> g uanaconda-mode-find-references

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?

Appendix

🔨 This module has no appendix yet. Write one?