It does seem like a bug, but also exactly the sort of thing that tree sitter solves. I bet this doesn't happen in python-ts-mode.
this post was submitted on 16 Jul 2024
4 points (100.0% liked)
Emacs
313 readers
3 users here now
A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!
Get Emacs
Rules
- Posts should be emacs related
- Be kind please
- Yes, we already know: Google results for "emacs" and "vi" link to each other. We good.
Emacs Resources
Emacs Tutorials
- Beginner’s Guide to Emacs
- Absolute Beginner's Guide to Emacs
- How to Learn Emacs: A Hand-drawn One-pager for Beginners
Useful Emacs configuration files and distributions
Quick pain-saver tip
founded 1 year ago
MODERATORS
Is it easy to integrate with elpy?
Pretty much unrelated AFAIK. At least in the setup I have it does mean that various hooks you may have set up may have to be tweaked. e.g. I had things on python-mode-hook
but now I have to use python-ts-mode-hook
.
For me it was
- install tree-sitter (
sudo apt install lib-tree-sitter-dev
) - build Emacs with tree-sitter
- configure tree-sitter with the snippet below
- mess with some config/hooks because my prog modes are now different
Some setups seem to make -ts-mode somehow aliased to -mode, and I don't know if that makes the hook issue automatically resolved (?). Apart from that, treesit-auto
seemed to be a low-friction way to get a setup:
My config:
(use-package treesit-auto
:custom
(treesit-auto-install 'prompt)
(treesit-font-lock-level 4)
:config
(treesit-auto-add-to-auto-mode-alist 'all)
(global-treesit-auto-mode))
Edit: and I can confirm that treesitter does fix your specific problem, unsurprisingly.