- Make sure you have Emacs with treesitter support:
M-:(treesit-available-p)RETshould returnt - Make sure you have installed python treesitter grammar
- Windows: download
libtree-sitter-python.dllfrom https://corwin.bru.st/emacs-tree-sitter/ into~/.emacs.d/tree-sitter/ - GNU/Linux: run
M-xtreesit-install-language-grammarRETtypepythonRETand do a couple of additionalyfor default options. You will need to havegitandC/Cppcompiler available as it would download repo and build grammar library.
- Windows: download
- Open python file and do
M-xpython-ts-modeRETto activate treesitter python mode. - Press
C-h mto 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-pylspFor others, check the their corresponding docs. Or use
venv. - In python buffer run
M-xeglotRET
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.
I guess you can do the same here 🤷♂️