this post was submitted on 16 Jul 2024
4 points (100.0% liked)

Emacs

305 readers
1 users here now

A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!

Get Emacs

Rules

  1. Posts should be emacs related
  2. Be kind please
  3. Yes, we already know: Google results for "emacs" and "vi" link to each other. We good.

Emacs Resources

Emacs Tutorials

Useful Emacs configuration files and distributions

Quick pain-saver tip

founded 1 year ago
MODERATORS
 

Take a look at the python code above. Because the word filter is a builtin function it gets highlighted differently than the rest of the code. The problem is, none of the occurrences of the word here relate to the builtin function and it semantically should not be any different from any other decorator or callable.

I honestly think that this is a bug with the syntax highlighter (as it should be easy to discern between a built-in function call and a method from another class, but if I could just disable syntax highlighting in python-mode for the specific keyword, it should be fine? Is that possible to do in elisp?

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 2 points 2 months ago* (last edited 2 months ago) (1 children)

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.

[–] [email protected] 1 points 2 months ago

Amazing, I think it's available on nixos as well. I will take it for a spin.