fxbois / web-mode

web template editing mode for emacs
https://web-mode.org
GNU General Public License v3.0
1.63k stars 262 forks source link

web-mode fails to recognize .mjs and .cjs files #1224

Closed tim-janik closed 2 years ago

tim-janik commented 2 years ago

Telling emacs to use web-mode for .mjs and .cjs files isn't enough to enable Javascript treatment of these file types. I suggest to add the following:

diff --git a/web-mode.el b/web-mode.el
index 1443dbe..e28f03f 100644
--- a/web-mode.el
+++ b/web-mode.el
@@ -926,7 +926,7 @@ Must be used in conjunction with web-mode-enable-block-face."

 (defvar web-mode-content-types
   '(("css"        . "\\.\\(s?css\\|css\\.erb\\)\\'")
-    ("javascript" . "\\.\\(js\\|js\\.erb\\)\\'")
+    ("javascript" . "\\.\\([mc]?js\\|js\\.erb\\)\\'")
     ("typescript" . "\\.\\(ts\\|ts\\.erb\\)\\'")
     ("json"       . "\\.\\(api\\|json\\|jsonld\\)\\'")
     ("jsx"        . "\\.[jt]sx\\'")
fxbois commented 2 years ago

done