- Make sure you have Emacs with treesitter support:
M-:
(treesit-available-p)
RET
should returnt
- Make sure you have installed python treesitter grammar
- Windows: download
libtree-sitter-python.dll
from https://corwin.bru.st/emacs-tree-sitter/ into~/.emacs.d/tree-sitter/
- GNU/Linux: run
M-x
treesit-install-language-grammar
RET
typepython
RET
and do a couple of additionaly
for default options. You will need to havegit
andC/Cpp
compiler available as it would download repo and build grammar library.
- Windows: download
- Open python file and do
M-x
python-ts-mode
RET
to activate treesitter python mode. - Press
C-h m
to see if python treesitter is in place, third line should state:Major mode for editing Python files, using tree-sitter library.
- Optional, auto enable treesitter for python:
(setq major-mode-remap-alist '((python-mode . python-ts-mode)))
- Install
eglot
(not needed for Emacs 29.1) - Install python language server, example for Debian 12:
$ sudo apt install python3-pylsp
For others, check the their corresponding docs. Or use
venv
. - In python buffer run
M-x
eglot
RET
It should state it is successfully connected.
For completion UI corfu
might work. Install and enable with
(global-corfu-mode)
.
Use (setq tab-always-indent 'complete)
to let you TAB
to trigger completion.
Default is C-M-i
.
$ sudo apt install python3-pylsp