Skip to content

Commit

Permalink
Use js2-mode for additional Node.js extensions.
Browse files Browse the repository at this point in the history
Node.js can file extensions to force ECMAScript (.mjs) versus
CommonJS (.cjs) module systems. They're both JavaScript files so use
js2-mode when editing them.
  • Loading branch information
byronclark authored and bbatsov committed Apr 14, 2023
1 parent ce86286 commit b57ff48
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* The keybinding for `proced` is now enabled unconditionally.
* Replace prelude-go backend with `lsp` instead of unmaintained tools.
* Use `rust-analyzer` as language server for prelude-rust and provide nicer syntax highlighting with `tree-sitter`.
* Use `js2-mode` for Node.js specific `.cjs` and `.mjs` extensions.

### Bugs fixed

Expand Down
7 changes: 4 additions & 3 deletions modules/prelude-js.el
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@

(require 'js2-mode)

(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
(add-to-list 'auto-mode-alist '("\\.pac\\'" . js2-mode))
(add-to-list 'interpreter-mode-alist '("node" . js2-mode))
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
(add-to-list 'auto-mode-alist '("\\.[cm]js\\'" . js2-mode))
(add-to-list 'auto-mode-alist '("\\.pac\\'" . js2-mode))
(add-to-list 'interpreter-mode-alist '("node" . js2-mode))

(with-eval-after-load 'js2-mode
(defun prelude-js-mode-defaults ()
Expand Down

0 comments on commit b57ff48

Please sign in to comment.