Skip to content

Latest commit

 

History

History
138 lines (115 loc) · 5.57 KB

README.org

File metadata and controls

138 lines (115 loc) · 5.57 KB

lang/python

Table of Contents

Description

Adds Python support to Doom Emacs.

  • Syntax checking (flycheck)
  • Snippets
  • Run tests (nose, pytest)
  • Auto-format (black), requires :editor format

Module Flags

  • +lsp Language Server Protocol support
  • +pyenv Python virtual environment support via pyenv
  • +conda Python virtual environment support via Conda
  • +poetry Python packaging, dependency management, and virtual environment support via Poetry
  • +cython Cython files support via Cython-mode

Plugins

Prerequisites

This module has no direct prerequisites. Here are some of its soft dependencies.

  • To run tests inside of Emacs:
    • 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:
  • pipenv requires pipenv
  • cython requires Cython

Language Server Protocol Support

This module must be enabled with the +lsp flag, and the :tools lsp module must be enabled. LSP will try pyls then mspyls; the first that is available.

To use Python Language Server (pyls) install it with pip install 'python-language-server[all]'

To use mspyls, install it with M-x lsp-install-server and add this to your private config.el:

(after! lsp-python-ms
  (set-lsp-priority! 'mspyls 1))

Features

This module supports LSP. It requires installation of Python Language Server or Microsoft Language Server, see LSP Support.

To enable support for auto-formatting with black enable :editor format-all in init.el file.

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 has the following variables to set extra arguments to ipython and jupyter shells:

;; ~/.doom.d/config.el
(setq +python-ipython-repl-args '("-i" "--simple-prompt" "--no-color-info"))
(setq +python-jupyter-repl-args '("--simple-prompt"))