Hi Léo,
I think I can actually speak a bit on this. As it stands, babel fontification operates by:
- sending the src block to a dedicated buffer
- turning on the relevant major mode for the language
- forcing font-lock of the entire buffer
- cloning the font-lock information for the entire buffer back to Org
In essence, every keystroke in a babel block causes font-lock lag equal to opening the file for the first time. As you can imagine, this adds up.
I think ideally Org would monitor which block you’re executing keystrokes in, and if there are a few in a row in the same org-src block keep the font-lock buffer alive and incrementally update the content and intelligently copy back font-lock changes. This has the potential to be much lower latency, but is also going to be hard to get right.
In the meantime, you could try executing something like this in your Org buffer (source):
(setq-local jit-lock-defer-time 0.05 jit-lock-stealth-time 1)
This sacrifices immediate font-lock accuracy for responsiveness.
All the best,
Timothy