diff --git a/modules/lang/python/README.org b/modules/lang/python/README.org new file mode 100644 index 000000000..91c011114 --- /dev/null +++ b/modules/lang/python/README.org @@ -0,0 +1,120 @@ +#+TITLE: lang/python +#+DATE: Oct, 2019 +#+SINCE: v2.0.9 +#+STARTUP: inlineimages + +* Table of Contents :TOC_3:noexport: +- [[#description][Description]] + - [[#module-flags][Module Flags]] + - [[#plugins][Plugins]] +- [[#prerequisites][Prerequisites]] + - [[#language-server-protocol-support][Language Server Protocol Support]] +- [[#features][Features]] + - [[#keybindings][Keybindings]] +- [[#configuration][Configuration]] + +* 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 [[https://github.com/pyenv/pyenv][pyenv]] ++ ~+conda~ Python virtual environment support via [[https://conda.io/en/latest/][Conda]] + +** Plugins ++ [[https://github.com/pythonic-emacs/anaconda-mode][anaconda-mode]]* ++ [[https://github.com/Wilfred/pyimport][pyimport]]* ++ [[https://github.com/emacs-pe/pyimpsort.el][pyimpsort]]* ++ [[https://melpa.org/#/nose][nose]]* ++ [[https://github.com/wbolster/emacs-python-pytest][python-pytest]]* ++ [[https://github.com/Wilfred/pip-requirements.el][pip-requirements]]* ++ [[https://github.com/pwalsh/pipenv.el][pipenv]]* ++ ~:editor format~ + + [[https://github.com/lassik/emacs-format-all-the-code][format-all]]* ++ ~+conda~ + + [[https://github.com/necaris/conda.el][conda]]* ++ ~+pyenv~ + + [[https://github.com/pythonic-emacs/pyenv-mode][pyenv]]* ++ ~+lsp~ and ~:tools lsp~ + + [[https://github.com/emacs-lsp/lsp-mode][lsp]] + + [[https://github.com/emacs-lsp/lsp-python-ms][lsp-python-ms]]* + +* 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 [[https://github.com/psf/black][Black]] for python files + + ~pip install black~ + ++ ~pyimport~ requires Python's module ~pyimport~: + + ~pip install pyimport~ + ++ Python virtual environments install instructions at: + + [[https://github.com/pyenv/pyenv][pyenv]] + + [[https://conda.io/en/latest/][Conda]] + ++ ~pipenv~ requires [[https://pipenv.readthedocs.io/en/latest/][pipenv]] + +** Language Server Protocol Support +Requires the ~+lsp~ flag and ~:tools lsp~ module to be enabled. +By default LSP will use Microsoft's language server if installed. + +To install the language server: +~M-x lsp-python-ms-setup~ +To update the server: +~M-x lsp-python-ms-update-server~ + +Alternatively you can use the [[https://pypi.org/project/python-language-server/][Python Language Server]] instead. +~pip install 'python-language-server[all]'~ + +* Features +This module supports LSP. It requires installation of [[https://pypi.org/project/python-language-server/][Python Language +Server]] or [[https://github.com/Microsoft/python-language-server][Microsoft Lnaguaje Server]], see [[Language Server Protocol Support][LSP Support]]. + +To enable support for auto-formatting with black enable ~:editor format-all~ in +~init.el~ file. + +** Keybindings + +| Binding | Description | +|---------------------+----------------------------------| +| ~ i i~ | ~Insert mising imports~ | +| ~ i r~ | ~Remove unused imports~ | +| ~ i s~ | ~Sort imports~ | +| ~ i o~ | ~Optimize imports~ | +| ~ t r~ | ~nosetests-again~ | +| ~ t a~ | ~nosetests-all~ | +| ~ t s~ | ~nosetests-one~ | +| ~ t v~ | ~nosetests-module~ | +| ~ t A~ | ~nosetests-pdb-all~ | +| ~ t O~ | ~nosetests-pdb-one~ | +| ~ t V~ | ~nosetests-pdb-module~ | +| ~ t f~ | ~python-pytest-file~ | +| ~ t k~ | ~python-pytest-file-dwin~ | +| ~ t t~ | ~python-pytest-function~ | +| ~ t m~ | ~python-pytest-function-dwim~ | +| ~ t r~ | ~python-pytest-repeat~ | +| ~ t p~ | ~python-pytest-popup~ | +| ~ f d~ | ~anaconda-mode-find-definitions~ | +| ~ f h~ | ~anaconda-mode-show-doc~ | +| ~ f a~ | ~anaconda-mode-find-assignments~ | +| ~ f f~ | ~anaconda-mode-find-file~ | +| ~ f u~ | ~anaconda-mode-find-references~ | + +* Configuration +This module has the following variables to set extra arguments to [[https://ipython.org/][ipython]] and +[[https://jupyter.org/][jupyter]] shells: + +#+BEGIN_SRC elisp +;; ~/.doom.d/config.el +(setq +python-ipython-repl-args '("-i" "--simple-prompt" "--no-color-info")) +(setq +python-jupyter-repl-args '("--simple-prompt")) +#+END_SRC