Add js2-mode configuration

This commit is contained in:
Tom Willemse 2017-12-30 23:02:38 -08:00
parent b9c50f793e
commit 897a674f32
2 changed files with 41 additions and 2 deletions

View file

@ -5,13 +5,14 @@ include ../../dotfiles.mk
AUTOLOADS_FILE = site-lisp/site-autoloads.el
UNWANTED = $(AUTOLOADS_FILE) site-lisp/flycheck_% site-lisp/flycheck-%
SITE_LISPS = $(addsuffix c,$(filter-out $(UNWANTED),$(wildcard site-lisp/*.el)))
INIT_LISPS = init/oni-org-init.elc $(addsuffix .elc,$(basename $(wildcard init/*.org)))
INIT_LISPS = init/oni-org-init.elc init/oni-js2-init.elc \
$(addsuffix .elc,$(basename $(wildcard init/*.org)))
VENDOR_DIRS = $(wildcard vendor-lisp/*)
.PHONE: all snippets
all: $(SITE_LISPS) init.elc $(INIT_LISPS) $(AUTOLOADS_FILE) snippets
init.el init/oni-org-init.el: init.org
init.el init/oni-org-init.el init/oni-js2-init.el: init.org
$(call tangle,emacs-lisp)
%.el: %.org

View file

@ -195,6 +195,15 @@ Computing Environment".
(setq auto-save-list-file-prefix (oni:data-location "auto-save-list/.saves-"))
#+END_SRC
*** Additional file type mappings
Load =*.js= files with [[JavaScript IDE mode]]. ~js2-mode~ is a better
JavaScript mode than plain old ~js-mode~.
#+BEGIN_SRC emacs-lisp
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
#+END_SRC
* Typographic style
Emacs being a text editor has options on how to handle your text.
@ -1134,6 +1143,35 @@ Computing Environment".
(add-hook 'lisp-mode-hook 'company-mode)
#+END_SRC
** JavaScript IDE mode
:PROPERTIES:
:header-args: :tangle "init/oni-js2-init.el"
:END:
Since ~js2-mode~ isn't loaded when Emacs starts put the
configuration in a different file so that it doesn't cause a
slowdown in startup time.
#+BEGIN_SRC emacs-lisp :tangle yes
(with-eval-after-load 'js2-mode (load "oni-js2-init"))
#+END_SRC
Keep the byte-compiler happy by requiring ~js2-mode~, by this time
it will have been loaded anyway.
#+BEGIN_SRC emacs-lisp
(require 'js2-mode)
#+END_SRC
Silence warnings about trailing commas in JavaScript code. I usually
write code that goes through Babel or something similar and doesn't
actually die when a trailing comma is present. Also this should
really be handled by a linter such as eslint.
#+BEGIN_SRC emacs-lisp
(setq js2-strict-trailing-comma-warning nil)
#+END_SRC
* Applications
- [[file:init/dired-init.org][Dired]] :: The Emacs file manager. Very powerful, and I don't use it