Closed iambumblehead closed 2 years ago
(setq mmm-parse-when-idle t)
should help.
But js2-mode
is incompatible with mmm-mode
. Try js-mode
instead, maybe.
@dgutov hey thank you I'm glad to read your response. I do have (setq mmm-parse-when-idle 't)
defined at the top (not inside any hook). What happens is, the file loads and the sub-region is not syntax-highlighted until I "touch" the file --eg, if I go to the template area an move or edit a tag, then the whole area gets syntax-highlighting and looks nice.
should js-mode be the new "default mode" for js?
That sounds like a bug: either inside mmm-mode
's code.
Or an incompatibility between the major modes, which they might need extra help with.
If the problem is with js2-mode
, then I suggest using js-mode
instead.
js2-mode
is good for "regular" JS code, and has some useful stuff for it.
It's not so great, OOTB, for React-style code. There are some extensions for it which can help (e.g. rjsx-mode
), you can try those. I don't recommend mixing it with mmm-mode
, though.
@dgutov it works with js-mode
the syntax highlighting looks a little plain compared to js2-mode but is OK. I'll upload a little screenshots js2-mode and js-mode, simply to share and no other reason
this calls (mmm-parse-buffer)
one time after one second and can be added to the mmm-mode hook. Its not ideal, but...
(run-at-time 1 nil (lambda() (mmm-parse-buffer)))
Here's the relevant issue: https://github.com/mooz/js2-mode/issues/124
Not on my roadmap currently, but maybe someday. The screenshots look pretty convincing.
'looping back to give a summary of what happened. The setup here uses eglot with typescript-language-server and flymake to get auto-completion and auto-linting and the result is amazing. This screenshot shows how "icons" are auto-suggested at the import expression --I did not open any files before screenshot and only opened the buffer file with emacs directly,
this was added to an eglot hook and to the mmm-mode hook, the delay is acceptable and not overly-intrusive,
(add-hook 'eglot-server-initialized-hook (lambda (server) (run-at-time 1 nil (lambda() (mmm-parse-buffer)))))
(add-hook 'mmm-mode-hook (lambda () (run-at-time 1 nil (lambda() (mmm-parse-buffer))))
other than these mmm-mode definitions, everything else are standard
(mmm-add-classes
'((js-vue
:submode web-mode
:face mmm-code-submode-face
:front ": `"
:front-offset (end-of-line 1)
:back-offset (end-of-line 1)
:back ">`")))
(mmm-add-mode-ext-class 'js2-mode nil 'js-vue)
(mmm-add-mode-ext-class 'js-mode nil 'js-vue)
eglot
does not require configuration, so after installing typescript-language-server and then eglot, this was added to my .emacs file
(require 'eglot)
I don't want to bother you and "@" your name dgutov, thank you for using time responding to me and my comments here. Your input is always appreciated by me.
and a little gif screenshot for fun
It's no bother.
I see that it's more or less working okay for you, and that's great. I feared the breakage might be more annoying.
when calling
mmm-parse-buffer
fromjs2-mode-hook
or frommmm-mode-hook
, the buffer is left in a broke state with incorrect syntax-highlighting and indentation. How does one run this command automatically?