From 67f2a66a850bcc124ffb192a6cdd60b24a40e110 Mon Sep 17 00:00:00 2001 From: Oliver Caldwell Date: Sat, 25 Oct 2014 15:55:12 +0100 Subject: [PATCH 1/2] Added Tern + more js2-mode integration. --- README.md | 20 ++++++++++++++++++++ spacemacs/packages.el | 26 +++++++++++--------------- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 292cda9aa..265285293 100644 --- a/README.md +++ b/README.md @@ -1365,6 +1365,23 @@ Test commands (start with `m t` or `m T`): ` m g` | go to definition using [emacs-jedi][jedi] ` m p` | add a breakpoint +#### JavaScript + +[js2-mode][] will activate for all `*.js` files, along with +[tern-auto-complete][] which will provide the best JavaScript +completion currently available. Just make sure you have the [tern][] +NPM module installed. + +Tern includes the following key bindings: + + Key Binding | Description +------------------|------------------------------------------------------------ +`M-.` | jump to the definition of the thing under the cursor. +`M-,` | brings you back to last place you were when you pressed M-.. +`C-c C-r` | rename the variable under the cursor. +`C-c C-c` | find the type of the thing under the cursor. +`C-c C-d` | find docs of the thing under the cursor. Press again to open the associated URL (if any). + #### R (ESS) **Important**: @@ -1517,3 +1534,6 @@ Thank you to the whole Emacs community from core developers to elisp hackers! [issues]: https://github.com/syl20bnr/spacemacs/issues [vundle]: https://github.com/gmarik/Vundle.vim [anzu]: https://github.com/syohex/emacs-anzu +[js2-mode]: https://github.com/mooz/js2-mode +[tern-auto-complete]: https://github.com/marijnh/tern/blob/master/emacs/tern-auto-complete.el +[tern]: http://ternjs.net/ diff --git a/spacemacs/packages.el b/spacemacs/packages.el index e2d49a131..039d1da1e 100644 --- a/spacemacs/packages.el +++ b/spacemacs/packages.el @@ -111,6 +111,7 @@ string-edit subword tagedit + tern-auto-complete undo-tree visual-regexp-steroids volatile-highlights @@ -1342,22 +1343,9 @@ of 2 characters. If INSERT? is not nil then the first key pressed is inserted (defun spacemacs/init-js2-mode () (use-package js2-mode - :commands (js2-minor-mode - ac-js2-mode) + :commands (js2-minor-mode) :init - (progn - (add-hook 'js-mode-hook 'js2-minor-mode) - (add-hook 'js2-mode-hook 'ac-js2-mode) - ;; the following manually installed packages are a hack because of unhealthy - ;; dependencies between js2-mode, ac-js2, skewer-mode etc... - (use-package ac-js2 - :ensure ac-js2 - :defer t) - (puthash 'ac-js2 'spacemacs spacemacs-all-packages) - (use-package js2-refactor - :ensure js2-refactor - :defer t) - (puthash 'js2-refactor 'spacemacs spacemacs-all-packages)))) + (add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode)))) (defun spacemacs/init-json-mode () (use-package json-mode @@ -1766,6 +1754,14 @@ of 2 characters. If INSERT? is not nil then the first key pressed is inserted (add-hook 'html-mode-hook (lambda () (tagedit-mode 1))) (spacemacs//diminish tagedit-mode " Ⓣ")))) +(defun spacemacs/init-tern-auto-complete () + (use-package tern-auto-complete + :defer t + :init + (progn + (tern-ac-setup) + (add-hook 'js2-mode-hook (lambda () (tern-mode t)))))) + (defun spacemacs/init-undo-tree () (use-package undo-tree :defer t From bd1c3c252c4a9b4e0cb9f9412caf7536f841d540 Mon Sep 17 00:00:00 2001 From: Oliver Caldwell Date: Sat, 25 Oct 2014 18:13:12 +0100 Subject: [PATCH 2/2] Updated README TOCs with JavaScript. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 265285293..be109dfc8 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,7 @@ _Jump to [Install](#install) for more info_ - [Inferior REPL process](#inferior-repl-process) - [Testing in Python](#testing-in-python) - [Other Python commands](#other-python-commands) + - [JavaScript](#javascript) - [R (ESS)](#r-ess) - [Inferior REPL process](#inferior-repl-process) - [Other R commands](#other-r-commands)