-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mmm-mode with typescript-ts-mode is very slow #142
Comments
Hi! tree-sitter does things a bit differently, and mmm-mode also has a peculiarity in how it reparses buffers (a certain implementation shortcut), so it's no surprise that large buffers can have performance problems with this combination. I'll look into it when I have more time, but before that, you can try setting up the native tree-sitter support for mixed languages (the "ranges" thing). Here's some documentation for it: https://www.gnu.org/software/emacs/manual/html_node/elisp/Multiple-Languages.html Note that this feature is also very new. For best results try Emacs 29.3 or newer. |
Dmitry - thanks for the quick feedback and for the pointer to the tree-sitter "ranges" feature (of which I was unaware; I'll see how far I can get with that.) -Lester |
Dmitry - the tree-sitter "ranges" feature is an effective workaround for my purposes. mmm-mode is nice w.r.t. truly switching modes, but the tree-sitter font-locking for multiple languages gets me most of the way there. Thanks again, Lester |
Glad it's working out for you! Perhaps you'll want to paste your config for typescript ranges here, for anybody having this problem in the meantime while this is unfixed. |
Hi Dmitry, Sure/thanks - see below. A few notes:
|
Looking good!
I would keep using it (if you can't switch to 29.3 entirely). There have been fixes related to ranges past 29.1, though I don't remember the exact details. |
Hi Dmitry, Thanks, I've now moved to emacs 29.3, facilitated by its recent arrival in Debian 12 backports. For completeness & in case it's helpful to someone, regarding the approach I listed in the previous comment in this thread,
Otherwise, this behavior of
which otherwise resulted, for me, in I also found it useful to add Regards, |
Yep, that makes sense. The manual page I originally linked to actually mentions this (the beginning of the page, second paragraph near the end), but the code examples don't, so it's easy enough to miss. I'll file a bug. Maybe you'll want to publish a public gist for "Angular templating setup with typescript-ts-mode"? Does that sound like an appropriate title? |
Hi Dmitry, Thanks, I see that reference now, and indeed it would be helpful to have that aspect considered in the examples. A gist is an excellent way to provide the foregoing info--thanks for the suggestion. Regards, |
Now added: emacs-mirror/emacs@e947e63b066 |
Thanks - and here is the gist (I thought I had posted it earlier, sorry): Angular templating setup with typescript-ts-mode |
Hello,
I have used
mmm-mode
for a while (thank you very much), together withtypescript-mode
.However, I have encountered a major slowdown when combining
mmm-mode
withtypescript-ts-mode
.I haven't been able to solve this myself, and would appreciate any advice or guidance which you may have.
I am using emacs-29.1 (https://packages.debian.org/bookworm-backports/emacs when it was at 1:29.1+1-5~bpo12+1) and mmm-mode 0.5.11.
I have simplified to use this
~/.emacs.el
:and this
test.ts
Typescript file (Angular syntax: the "template" section is HTML):test.ts.txt
I have customized
treesit.el
with the one-line fix in #138 (comment)(I also tried https://github.com/emacs-mirror/emacs/blob/emacs-29.3/lisp/treesit.el but encountered the same behavior.)
When I use emacs
profiler-start
...profiler-stop
...profiler-report
, and move (up/down arrow) in and out of the "template" code (h4 test /h4), I see:With a larger .ts file (several hundred lines of HTML in the template), emacs becomes almost unresponsive.
A profiler report for that case is here:
I also enabled "LOUDLY" in
treesit.el
by changing the below variable from default (nil
) tot
:When
mmm-mode
is not enabled (with the abovetest.ts
file), the Messages buffer contains just:However, with
mmm-mode
enabled for this file, the Messages buffer continuously streams "LOUDLY" messages (tail shown here):At a high level, it seems to me that the fontifying running continuously (with mmm-mode enabled) is what creates such a heavy load.
If you have any suggestions on how to narrow this down, or improve the behavior, please advise.
Thanks very much,
Lester
The text was updated successfully, but these errors were encountered: