aboutsummaryrefslogtreecommitdiffstats
path: root/emacs
diff options
context:
space:
mode:
authorGravatar Tom Willemse2017-12-30 23:02:38 -0800
committerGravatar Tom Willemse2017-12-30 23:02:38 -0800
commit897a674f3230609fc56225c12594a524dfe48352 (patch)
treef7e4c30408dd46456272e453fc6014d3a955f9c2 /emacs
parentb9c50f793e20594ae9c935498b479537e2dfdfce (diff)
downloadnew-dotfiles-897a674f3230609fc56225c12594a524dfe48352.tar.gz
new-dotfiles-897a674f3230609fc56225c12594a524dfe48352.zip
Add js2-mode configuration
Diffstat (limited to 'emacs')
-rw-r--r--emacs/.emacs.d/GNUmakefile5
-rw-r--r--emacs/.emacs.d/init.org38
2 files changed, 41 insertions, 2 deletions
diff --git a/emacs/.emacs.d/GNUmakefile b/emacs/.emacs.d/GNUmakefile
index a6b3f25..83b9876 100644
--- a/emacs/.emacs.d/GNUmakefile
+++ b/emacs/.emacs.d/GNUmakefile
@@ -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
diff --git a/emacs/.emacs.d/init.org b/emacs/.emacs.d/init.org
index 9b311b9..74ab5f5 100644
--- a/emacs/.emacs.d/init.org
+++ b/emacs/.emacs.d/init.org
@@ -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