mirror of
https://github.com/doomemacs/doomemacs.git
synced 2026-04-27 15:20:52 -07:00
docs(python): update and mention ty
- Remove mention of obsolete LSP servers. - Recommend astral-sh/ty over others. - Remove defunct anaconda keybinds.
This commit is contained in:
parent
62ee557c32
commit
1d51b7a1a0
1 changed files with 47 additions and 40 deletions
|
|
@ -23,8 +23,9 @@ This module adds [[https://www.python.org/][Python]] support to Doom Emacs.
|
|||
- +cython ::
|
||||
Enable support for Cython files support.
|
||||
- +lsp ::
|
||||
Enable LSP support for ~python-mode~. Requires [[doom-module::tools lsp]] and a
|
||||
langserver (=pyls=, =jedi=, =ruff=, or =pyright=).
|
||||
Enable LSP support for ~python-mode~ and ~python-ts-mode~. Requires
|
||||
[[doom-module::tools lsp]] and an LSP server (e.g. =ty= (recommended), =pyright=,
|
||||
=basedpyright=, =jedi=, =ruff=).
|
||||
- +poetry ::
|
||||
Enable Python packaging, dependency management, and virtual environment
|
||||
support via [[https://python-poetry.org/][Poetry]].
|
||||
|
|
@ -80,57 +81,63 @@ This module has no hard requirements, but softly depends on:
|
|||
- ~cython~ requires [[https://cython.org/][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.
|
||||
For LSP support the [[doom-module::tools lsp]] module must be enabled, along with
|
||||
this module's [[doom-module:+lsp]] flag. It supports anything that lsp-mode and
|
||||
Eglot support. [[https://github.com/astral-sh/ty][ty]] is recommended. Some can be installed from within Emacs using
|
||||
~M-x lsp-install-server~, others are available through OS package managers or pip.
|
||||
E.g.
|
||||
|
||||
An alternative LSP server can be used by installing them through the
|
||||
[[cmd:][lsp-install-server]] command, or an external package manager. For example:
|
||||
- To install *basedpyright*: ~$ pip install basedpyright~
|
||||
- To install *pyright*: ~$ pip install pyright~ or ~$ npm i -g pyright~.
|
||||
- To install [[https://pypi.org/project/python-language-server/][*pyls*]]: ~$ pip install python-language-server[all]~.
|
||||
- To install *mspyls*: ~M-x lsp-install-server RET mspyls~.
|
||||
- [[https://docs.astral.sh/ty/installation][ty]] ::
|
||||
~$ pip install ty~
|
||||
- basedpyright ::
|
||||
~$ pip install basedpyright~
|
||||
- pyright ::
|
||||
~$ pip install pyright~ or ~$ npm i -g pyright~.
|
||||
|
||||
** Formatter
|
||||
Formatting is handled by the [[doom-module::editor format]] module. Python buffers
|
||||
use [[https://black.readthedocs.io/en/stable/getting_started.html#installation][black]], by default. [[https://github.com/astral-sh/ruff][ruff]] is also supported:
|
||||
#+begin_src elisp
|
||||
;;; Add to $DOOMDIR/config.el
|
||||
(after! python
|
||||
(set-formatter! 'ruff :modes '(python-mode python-ts-mode)))
|
||||
#+end_src
|
||||
|
||||
Formatting is handled using the [[doom-module::editor format]] module via [[https://black.readthedocs.io/en/stable/getting_started.html#installation][black]].
|
||||
Formatters can also be set per-project in a =.dir-locals.el= file or file-local
|
||||
variables. See [[doom-module::editor format]]'s documentation for details.
|
||||
|
||||
* TODO Usage
|
||||
#+begin_quote
|
||||
/This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]]
|
||||
#+end_quote
|
||||
|
||||
This module supports LSP. It requires installation of [[https://pypi.org/project/python-language-server/][Python Language Server]],
|
||||
[[https://github.com/Microsoft/python-language-server][Microsoft Language Server]], or [[https://github.com/microsoft/pyright][pyright]], see [[Language Server Protocol Support][LSP Support]].
|
||||
This module supports LSP. It requires an LSP server, like [[https://github.com/astral-sh/ty][ty]] (recommended). See [[Language Server Protocol
|
||||
Support][LSP Support]].
|
||||
|
||||
To enable support for auto-formatting with black enable [[doom-module::editor format]].
|
||||
To enable support for auto-formatting with black enable [[doom-module::editor
|
||||
format]].
|
||||
|
||||
** Keybindings
|
||||
| Binding | Description |
|
||||
|-------------------+----------------------------------|
|
||||
| [[kbd:][<localleader> c c]] | ~Compile Cython buffer~ |
|
||||
| [[kbd:][<localleader> i i]] | ~Insert missing imports~ |
|
||||
| [[kbd:][<localleader> i r]] | ~Remove unused imports~ |
|
||||
| [[kbd:][<localleader> i s]] | ~Sort imports~ |
|
||||
| [[kbd:][<localleader> i o]] | ~Optimize imports~ |
|
||||
| [[kbd:][<localleader> t r]] | ~nosetests-again~ |
|
||||
| [[kbd:][<localleader> t a]] | ~nosetests-all~ |
|
||||
| [[kbd:][<localleader> t s]] | ~nosetests-one~ |
|
||||
| [[kbd:][<localleader> t v]] | ~nosetests-module~ |
|
||||
| [[kbd:][<localleader> t A]] | ~nosetests-pdb-all~ |
|
||||
| [[kbd:][<localleader> t O]] | ~nosetests-pdb-one~ |
|
||||
| [[kbd:][<localleader> t V]] | ~nosetests-pdb-module~ |
|
||||
| [[kbd:][<localleader> t f]] | ~python-pytest-file~ |
|
||||
| [[kbd:][<localleader> t k]] | ~python-pytest-file-dwim~ |
|
||||
| [[kbd:][<localleader> t t]] | ~python-pytest-function~ |
|
||||
| [[kbd:][<localleader> t m]] | ~python-pytest-function-dwim~ |
|
||||
| [[kbd:][<localleader> t r]] | ~python-pytest-repeat~ |
|
||||
| [[kbd:][<localleader> t p]] | ~python-pytest-popup~ |
|
||||
| [[kbd:][<localleader> g d]] | ~anaconda-mode-find-definitions~ |
|
||||
| [[kbd:][<localleader> g h]] | ~anaconda-mode-show-doc~ |
|
||||
| [[kbd:][<localleader> g a]] | ~anaconda-mode-find-assignments~ |
|
||||
| [[kbd:][<localleader> g f]] | ~anaconda-mode-find-file~ |
|
||||
| [[kbd:][<localleader> g u]] | ~anaconda-mode-find-references~ |
|
||||
| Binding | Description |
|
||||
|-------------------+-----------------------------|
|
||||
| [[kbd:][<localleader> c c]] | ~Compile Cython buffer~ |
|
||||
| [[kbd:][<localleader> i i]] | ~Insert missing imports~ |
|
||||
| [[kbd:][<localleader> i r]] | ~Remove unused imports~ |
|
||||
| [[kbd:][<localleader> i s]] | ~Sort imports~ |
|
||||
| [[kbd:][<localleader> i o]] | ~Optimize imports~ |
|
||||
| [[kbd:][<localleader> t r]] | ~nosetests-again~ |
|
||||
| [[kbd:][<localleader> t a]] | ~nosetests-all~ |
|
||||
| [[kbd:][<localleader> t s]] | ~nosetests-one~ |
|
||||
| [[kbd:][<localleader> t v]] | ~nosetests-module~ |
|
||||
| [[kbd:][<localleader> t A]] | ~nosetests-pdb-all~ |
|
||||
| [[kbd:][<localleader> t O]] | ~nosetests-pdb-one~ |
|
||||
| [[kbd:][<localleader> t V]] | ~nosetests-pdb-module~ |
|
||||
| [[kbd:][<localleader> t f]] | ~python-pytest-file~ |
|
||||
| [[kbd:][<localleader> t k]] | ~python-pytest-file-dwim~ |
|
||||
| [[kbd:][<localleader> t t]] | ~python-pytest-function~ |
|
||||
| [[kbd:][<localleader> t m]] | ~python-pytest-function-dwim~ |
|
||||
| [[kbd:][<localleader> t r]] | ~python-pytest-repeat~ |
|
||||
| [[kbd:][<localleader> t p]] | ~python-pytest-popup~ |
|
||||
|
||||
* TODO Configuration
|
||||
#+begin_quote
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue