-
Notifications
You must be signed in to change notification settings - Fork 35
Description
Hello!
Thanks for your work on this package!
I've been trying to set up this mode for use inside julia-mode and julia-ts-mode. It seems to work well for inline html and markdown
(html"""<>""" and md"""<>""") including indentation and font locking, but breaks down for javascript. As for font-locking, it works when I set the submode to javascript-mode, but not when I set it to js-mode which the former is an alias for, nor if I set it to use js2-mode. Both of the latter work fine on plain .js files.
Indentation is more quirky and I haven't been able to make it work at all for javascript - in md and html blocks it works fine, but in js blocks it seems to revert to julia's indentation function - pressing tab results in a [No matches] message unless tab-always-indent has been set to t or nil, whereas tab seems to do nothing (since julia does not want to indent that line).
Furthermore, the same happens in julia-ts-mode. In that case I get nice fontlocking inside of <script language="Javascript"> tags inside of html""" - but indentation seems to revert to the indentation of the html block (ie all code is indented one indent further than the script tag itself, but not further, eg inside a function). In that case I also notice that emacs is lagging, eg scrolling is much slower than when mmm-mode is turned off. I also get promptw regarding a missing linter and a missing lsp server which lets ignore for now.
emacs 29.2 from emacsforosx.com on macos 14.6 aarch64 with mmm-mode 20240222 from melpa, julia-mode 20240506.1205 from melap, julia-ts-mode 20230921.1433 from melpa, built-in js-ts-mode, js2-mode 20240418.6, and built-in js-mode.
[EDIT]
sample code:
md"""
## Hello
world
"""
js"""
console.log("hello");
function x() {
}
let y=1;
"""
html"""
<script language="Javascript">
let x = 1;
function y() {
return true;
}
</script>
"""
configuration:
(defun my/mmm-julia-auto-class (lang &optional submode)
"Define a mmm-mode class for LANG in `markdown-mode' using SUBMODE.
If SUBMODE is not provided, use `LANG-mode' by default."
(let ((class (intern (concat "julia-" lang)))
(submode (or submode (intern (concat lang "-mode"))))
(front (concat lang "\"\"\""))
(back "^\"\"\""))
(mmm-add-classes (list (list class :submode submode :front front :back back)))
(mmm-add-mode-ext-class 'julia-mode nil class)
(mmm-add-mode-ext-class 'julia-ts-mode nil class)))
(my/mmm-julia-auto-class "md" 'markdown-mode)
(my/mmm-julia-auto-class "js" 'javascript-mode)
(my/mmm-julia-auto-class "html" 'html-mode)
[EDIT 2]:
Interestingly, but not entirely related, I notice that vscode fontifies the js block but not the html or markdown blocks.