2015-01-14 04:12:56 +00:00
|
|
|
;;; packages.el --- Javascript Layer packages File for Spacemacs
|
|
|
|
;;
|
2016-01-12 02:40:54 +00:00
|
|
|
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
|
2015-01-14 04:12:56 +00:00
|
|
|
;;
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
2015-04-19 03:40:24 +00:00
|
|
|
(setq javascript-packages
|
2014-12-07 17:57:09 +00:00
|
|
|
'(
|
2014-12-14 03:49:24 +00:00
|
|
|
coffee-mode
|
2015-04-09 03:57:22 +00:00
|
|
|
company
|
2016-05-30 02:39:21 +00:00
|
|
|
(company-tern :toggle (configuration-layer/package-usedp 'company))
|
2015-07-05 19:27:32 +00:00
|
|
|
evil-matchit
|
2014-12-23 03:51:44 +00:00
|
|
|
flycheck
|
2016-04-05 04:08:34 +00:00
|
|
|
ggtags
|
|
|
|
helm-gtags
|
2015-08-26 01:02:51 +00:00
|
|
|
js-doc
|
2014-12-07 17:57:09 +00:00
|
|
|
js2-mode
|
|
|
|
js2-refactor
|
2014-12-23 03:51:44 +00:00
|
|
|
json-mode
|
2015-05-19 06:39:51 +00:00
|
|
|
json-snatcher
|
2016-06-21 23:03:18 +00:00
|
|
|
(tern :toggle (spacemacs//tern-detect))
|
2015-04-26 06:38:38 +00:00
|
|
|
web-beautify
|
2015-09-11 02:41:50 +00:00
|
|
|
skewer-mode
|
|
|
|
livid-mode
|
2015-04-19 03:40:24 +00:00
|
|
|
))
|
2014-12-07 17:57:09 +00:00
|
|
|
|
2014-12-14 03:49:24 +00:00
|
|
|
(defun javascript/init-coffee-mode ()
|
|
|
|
(use-package coffee-mode
|
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(defun javascript/coffee-indent ()
|
|
|
|
(if (coffee-line-wants-indent)
|
|
|
|
;; We need to insert an additional tab because the last line was special.
|
|
|
|
(coffee-insert-spaces (+ (coffee-previous-indent) coffee-tab-width))
|
|
|
|
;; otherwise keep at the same indentation level
|
|
|
|
(coffee-insert-spaces (coffee-previous-indent)))
|
|
|
|
)
|
2015-04-20 10:19:29 +00:00
|
|
|
;; indent to right position after `evil-open-below' and `evil-open-above'
|
2014-12-14 03:49:24 +00:00
|
|
|
(add-hook 'coffee-mode-hook '(lambda ()
|
|
|
|
(setq indent-line-function 'javascript/coffee-indent
|
|
|
|
evil-shift-width coffee-tab-width))))))
|
|
|
|
|
2016-05-30 02:39:21 +00:00
|
|
|
(defun javascript/post-init-company ()
|
|
|
|
(spacemacs|add-company-hook js2-mode))
|
2015-08-26 01:02:51 +00:00
|
|
|
|
2016-05-30 02:39:21 +00:00
|
|
|
(defun javascript/init-company-tern ()
|
|
|
|
(use-package company-tern
|
|
|
|
:if (and (configuration-layer/package-usedp 'company)
|
|
|
|
(configuration-layer/package-usedp 'tern))
|
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(push 'company-tern company-backends-js2-mode)))
|
2015-08-26 01:02:51 +00:00
|
|
|
|
2015-04-11 02:23:16 +00:00
|
|
|
(defun javascript/post-init-flycheck ()
|
2016-01-27 20:08:25 +00:00
|
|
|
(dolist (mode '(coffee-mode js2-mode json-mode))
|
|
|
|
(spacemacs/add-flycheck-hook mode)))
|
2014-12-23 03:51:44 +00:00
|
|
|
|
2016-04-05 04:08:34 +00:00
|
|
|
(defun javascript/post-init-ggtags ()
|
2016-08-15 19:24:44 +00:00
|
|
|
(add-hook 'js2-mode-local-vars-hook #'spacemacs/ggtags-mode-enable))
|
2016-04-05 04:08:34 +00:00
|
|
|
|
|
|
|
(defun javascript/post-init-helm-gtags ()
|
|
|
|
(spacemacs/helm-gtags-define-keys-for-mode 'js2-mode))
|
|
|
|
|
2015-08-26 01:02:51 +00:00
|
|
|
(defun javascript/init-js-doc ()
|
|
|
|
(use-package js-doc
|
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(defun spacemacs/js-doc-require ()
|
|
|
|
"Lazy load js-doc"
|
|
|
|
(require 'js-doc))
|
|
|
|
(add-hook 'js2-mode-hook 'spacemacs/js-doc-require)
|
|
|
|
|
|
|
|
(defun spacemacs/js-doc-set-key-bindings (mode)
|
|
|
|
"Setup the key bindings for `js2-doc' for the given MODE."
|
2016-08-08 10:36:44 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode mode "mrd" "documentation")
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "rdb" 'js-doc-insert-file-doc)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "rdf" 'js-doc-insert-function-doc)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "rdt" 'js-doc-insert-tag)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "rdh" 'js-doc-describe-tag))
|
2015-08-26 01:02:51 +00:00
|
|
|
(spacemacs/js-doc-set-key-bindings 'js2-mode))))
|
|
|
|
|
2014-12-07 17:57:09 +00:00
|
|
|
(defun javascript/init-js2-mode ()
|
|
|
|
(use-package js2-mode
|
|
|
|
:defer t
|
2014-12-17 18:43:42 +00:00
|
|
|
:init
|
|
|
|
(progn
|
2014-12-17 23:54:58 +00:00
|
|
|
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
|
2016-02-27 13:56:42 +00:00
|
|
|
;; Required to make imenu functions work correctly
|
2014-12-17 23:54:58 +00:00
|
|
|
(add-hook 'js2-mode-hook 'js2-imenu-extras-mode))
|
2014-12-07 17:57:09 +00:00
|
|
|
:config
|
|
|
|
(progn
|
2016-04-03 04:12:28 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode 'js2-mode "mh" "documentation")
|
|
|
|
(spacemacs/declare-prefix-for-mode 'js2-mode "mg" "goto")
|
|
|
|
(spacemacs/declare-prefix-for-mode 'js2-mode "mr" "refactor")
|
2015-07-31 03:20:54 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode 'js2-mode "mz" "folding")
|
2016-04-03 04:12:28 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'js2-mode
|
|
|
|
"w" 'js2-mode-toggle-warnings-and-errors
|
|
|
|
"zc" 'js2-mode-hide-element
|
|
|
|
"zo" 'js2-mode-show-element
|
|
|
|
"zr" 'js2-mode-show-all
|
|
|
|
"ze" 'js2-mode-toggle-element
|
|
|
|
"zF" 'js2-mode-toggle-hide-functions
|
|
|
|
"zC" 'js2-mode-toggle-hide-comments))))
|
2014-12-07 17:57:09 +00:00
|
|
|
|
2015-07-05 19:27:32 +00:00
|
|
|
(defun javascript/post-init-evil-matchit ()
|
|
|
|
(add-hook `js2-mode `turn-on-evil-matchit-mode))
|
|
|
|
|
2014-12-07 17:57:09 +00:00
|
|
|
(defun javascript/init-js2-refactor ()
|
|
|
|
(use-package js2-refactor
|
|
|
|
:defer t
|
2014-12-19 02:39:41 +00:00
|
|
|
:init
|
|
|
|
(progn
|
2015-08-26 00:57:56 +00:00
|
|
|
(defun spacemacs/js2-refactor-require ()
|
2014-12-19 02:39:41 +00:00
|
|
|
"Lazy load js2-refactor"
|
|
|
|
(require 'js2-refactor))
|
2015-08-26 00:57:56 +00:00
|
|
|
(add-hook 'js2-mode-hook 'spacemacs/js2-refactor-require)
|
|
|
|
|
|
|
|
(defun spacemacs/js2-refactor-set-key-bindings (mode)
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "mr3" "ternary")
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "r3i" 'js2r-ternary-to-if)
|
2014-12-07 17:57:09 +00:00
|
|
|
|
2015-08-26 00:57:56 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode mode "mra" "add/args")
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "rag" 'js2r-add-to-globals-annotation)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "rao" 'js2r-arguments-to-object)
|
2014-12-07 17:57:09 +00:00
|
|
|
|
2015-08-26 00:57:56 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode mode "mrb" "barf")
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "rba" 'js2r-forward-barf)
|
2014-12-07 17:57:09 +00:00
|
|
|
|
2015-08-26 00:57:56 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode mode "mrc" "contract")
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "rca" 'js2r-contract-array)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "rco" 'js2r-contract-object)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "rcu" 'js2r-contract-function)
|
2014-12-07 17:57:09 +00:00
|
|
|
|
2015-08-26 00:57:56 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode mode "mre" "expand/extract")
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "rea" 'js2r-expand-array)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "ref" 'js2r-extract-function)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "rem" 'js2r-extract-method)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "reo" 'js2r-expand-object)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "reu" 'js2r-expand-function)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "rev" 'js2r-extract-var)
|
2014-12-07 17:57:09 +00:00
|
|
|
|
2015-08-26 00:57:56 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode mode "mri" "inline/inject/introduct")
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "rig" 'js2r-inject-global-in-iife)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "rip" 'js2r-introduce-parameter)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "riv" 'js2r-inline-var)
|
2014-12-07 17:57:09 +00:00
|
|
|
|
2015-08-26 00:57:56 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode mode "mrl" "localize/log")
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "rlp" 'js2r-localize-parameter)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "rlt" 'js2r-log-this)
|
2014-12-07 17:57:09 +00:00
|
|
|
|
2015-08-26 00:57:56 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode mode "mrr" "rename")
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "rrv" 'js2r-rename-var)
|
2014-12-07 17:57:09 +00:00
|
|
|
|
2015-08-26 00:57:56 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode mode "mrs" "split/slurp")
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "rsl" 'js2r-forward-slurp)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "rss" 'js2r-split-string)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "rsv" 'js2r-split-var-declaration)
|
2014-12-07 17:57:09 +00:00
|
|
|
|
2015-08-26 00:57:56 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode mode "mrt" "toggle")
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "rtf" 'js2r-toggle-function-expression-and-declaration)
|
2014-12-07 17:57:09 +00:00
|
|
|
|
2015-08-26 00:57:56 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode mode "mru" "unwrap")
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "ruw" 'js2r-unwrap)
|
2014-12-07 17:57:09 +00:00
|
|
|
|
2015-08-26 00:57:56 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode mode "mrv" "var")
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "rvt" 'js2r-var-to-this)
|
2014-12-07 17:57:09 +00:00
|
|
|
|
2015-08-26 00:57:56 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode mode "mrw" "wrap")
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "rwi" 'js2r-wrap-buffer-in-iife)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "rwl" 'js2r-wrap-in-for-loop)
|
2014-12-07 17:57:09 +00:00
|
|
|
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "k" 'js2r-kill)
|
2015-11-23 21:08:28 +00:00
|
|
|
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "mx" "text")
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "mxm" "move")
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "xmj" 'js2r-move-line-down)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode "xmk" 'js2r-move-line-up))
|
2015-08-26 00:57:56 +00:00
|
|
|
|
|
|
|
(spacemacs/js2-refactor-set-key-bindings 'js2-mode))))
|
2014-12-07 17:57:09 +00:00
|
|
|
|
2014-12-23 03:51:44 +00:00
|
|
|
(defun javascript/init-json-mode ()
|
|
|
|
(use-package json-mode
|
|
|
|
:defer t))
|
|
|
|
|
2015-05-19 06:39:51 +00:00
|
|
|
(defun javascript/init-json-snatcher ()
|
|
|
|
(use-package json-snatcher
|
|
|
|
:defer t
|
|
|
|
:config
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'json-mode
|
|
|
|
"hp" 'jsons-print-path)
|
2015-05-19 06:39:51 +00:00
|
|
|
))
|
|
|
|
|
2014-12-07 17:57:09 +00:00
|
|
|
(defun javascript/init-tern ()
|
|
|
|
(use-package tern
|
|
|
|
:defer t
|
2016-05-10 10:56:18 +00:00
|
|
|
:diminish tern-mode
|
2014-12-19 02:39:41 +00:00
|
|
|
:init (add-hook 'js2-mode-hook 'tern-mode)
|
2014-12-07 17:57:09 +00:00
|
|
|
:config
|
|
|
|
(progn
|
2015-10-20 12:30:21 +00:00
|
|
|
(when javascript-disable-tern-port-files
|
|
|
|
(add-to-list 'tern-command "--no-port-file" 'append))
|
2016-06-21 23:03:18 +00:00
|
|
|
(spacemacs//set-tern-key-bindings 'js2-mode))))
|
2015-04-03 21:12:56 +00:00
|
|
|
|
2015-04-26 06:38:38 +00:00
|
|
|
(defun javascript/init-web-beautify ()
|
|
|
|
(use-package web-beautify
|
|
|
|
:defer t
|
|
|
|
:init
|
2015-04-28 04:02:35 +00:00
|
|
|
(progn
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'js2-mode "=" 'web-beautify-js)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'json-mode "=" 'web-beautify-js)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'web-mode "=" 'web-beautify-html)
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'css-mode "=" 'web-beautify-css))))
|
2015-09-11 02:41:50 +00:00
|
|
|
|
|
|
|
(defun javascript/init-skewer-mode ()
|
|
|
|
(use-package skewer-mode
|
|
|
|
:defer t
|
2016-05-10 10:56:18 +00:00
|
|
|
:diminish skewer-mode
|
2016-01-26 16:31:15 +00:00
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(spacemacs/register-repl 'skewer-mode 'spacemacs/skewer-start-repl "skewer")
|
|
|
|
(add-hook 'js2-mode-hook 'skewer-mode))
|
2015-09-11 02:41:50 +00:00
|
|
|
:config
|
|
|
|
(progn
|
2016-01-21 16:50:51 +00:00
|
|
|
(defun spacemacs/skewer-start-repl ()
|
|
|
|
"Attach a browser to Emacs and start a skewer REPL."
|
|
|
|
(interactive)
|
|
|
|
(run-skewer)
|
|
|
|
(skewer-repl))
|
|
|
|
|
|
|
|
(defun spacemacs/skewer-load-buffer-and-focus ()
|
|
|
|
"Execute whole buffer in browser and switch to REPL in insert state."
|
|
|
|
(interactive)
|
|
|
|
(skewer-load-buffer)
|
|
|
|
(skewer-repl)
|
Use evil in holy-mode
Motivation
While disabling Evil in holy-mode makes its implementation shorter and
sounds elegant on the paper, in practice it puts a big burden on the
configuration parts which need to know if Evil is enable or not. This is
a bad separation of concerns and the bunch of fixes that we were forced
to do in the past weeks shows this issue. Those fixes were about
removing the knowledge of the activation of Evil by implementing new
dispatching functions to be used by layers, this is cumbersome and makes
Spacemacs layer configuration more subtle which is not good. There was
additional bad consequences of the removal of Evil state like the
impossibility to use Evil lisp state or iedit states, or we would have
been forced to implement a temporary activation of Evil which is
awkward.
Instead I reintroduce Evil as the central piece of Spacemacs design thus
Evil is now re-enabled in holy-mode. It provides the abstraction we need
to isolate editing styles and be able to grow the Spacemacs
configuration coverage sanely. Layers don't need to check whether the
holy mode is active or not and they don't need to know if Evil is
available (it is always available). We also don't need to write
additional dispatching functions, this is the job of Evil, and I think
it provides everything for this. Ideally configuration layer should be
implemented with only Evil in mind and the holy-mode (and hybrid-mode)
should magically make it work for Emacs style users, for instance we can
freely use `evil-insert-state` anywhere in the code without any guard.
Evil is now even more part of Spacemacs, we can really say that
Spacemacs is Emacs+Evil which is now an indivisible pair. Spacemacs
needed this stable API to continue on the right track.
While these changes should be rather transparent to the user, I'm sorry
for this experimental period, I failed to see all the implications of
such a change, I was just excited about the possibility to make Evil
optional. The reality is that Spacemacs has to embrace it and keep its
strong position on being Emacs+Evil at the core.
Implementation
- insert, motion and normal states are forced to emacs state using an
advice on `evil-insert-state`, `evil-motion-state` and
`evil-normal-state` respectively. These functions can be used freely in
the layer configuration.
- A new general hook `spacemacs-editing-style-hook` allow to hook any
code that need to be configured based on the editing style. Functions
hooked to this hook takes the current style as parameter, this
basically generalize the hook used to setup hjkl navigation bindings.
- ESC has been removed from the emacs state map.
- Revert unneeded changes
- Revert "evil: enter insert-state only from normal-state"
commit bdd702dfbe302206bbc989c7a0832daba087a781.
- Revert "avoid being evil in deft with emacs editing style"
commit f3a16f49ed27cc8cf05f23f93b006d6e04235381.
Additional changes
All editing style packages have been moved to a layer called
`spacemacs-editing-styles`
Notes
I did not have time to attack hybrid mode, I should be able to do it
later.
2016-03-13 23:41:18 +00:00
|
|
|
(evil-insert-state))
|
2016-01-21 16:50:51 +00:00
|
|
|
|
|
|
|
(defun spacemacs/skewer-eval-defun-and-focus ()
|
|
|
|
"Execute function at point in browser and switch to REPL in insert state."
|
|
|
|
(interactive)
|
|
|
|
(skewer-eval-defun)
|
|
|
|
(skewer-repl)
|
Use evil in holy-mode
Motivation
While disabling Evil in holy-mode makes its implementation shorter and
sounds elegant on the paper, in practice it puts a big burden on the
configuration parts which need to know if Evil is enable or not. This is
a bad separation of concerns and the bunch of fixes that we were forced
to do in the past weeks shows this issue. Those fixes were about
removing the knowledge of the activation of Evil by implementing new
dispatching functions to be used by layers, this is cumbersome and makes
Spacemacs layer configuration more subtle which is not good. There was
additional bad consequences of the removal of Evil state like the
impossibility to use Evil lisp state or iedit states, or we would have
been forced to implement a temporary activation of Evil which is
awkward.
Instead I reintroduce Evil as the central piece of Spacemacs design thus
Evil is now re-enabled in holy-mode. It provides the abstraction we need
to isolate editing styles and be able to grow the Spacemacs
configuration coverage sanely. Layers don't need to check whether the
holy mode is active or not and they don't need to know if Evil is
available (it is always available). We also don't need to write
additional dispatching functions, this is the job of Evil, and I think
it provides everything for this. Ideally configuration layer should be
implemented with only Evil in mind and the holy-mode (and hybrid-mode)
should magically make it work for Emacs style users, for instance we can
freely use `evil-insert-state` anywhere in the code without any guard.
Evil is now even more part of Spacemacs, we can really say that
Spacemacs is Emacs+Evil which is now an indivisible pair. Spacemacs
needed this stable API to continue on the right track.
While these changes should be rather transparent to the user, I'm sorry
for this experimental period, I failed to see all the implications of
such a change, I was just excited about the possibility to make Evil
optional. The reality is that Spacemacs has to embrace it and keep its
strong position on being Emacs+Evil at the core.
Implementation
- insert, motion and normal states are forced to emacs state using an
advice on `evil-insert-state`, `evil-motion-state` and
`evil-normal-state` respectively. These functions can be used freely in
the layer configuration.
- A new general hook `spacemacs-editing-style-hook` allow to hook any
code that need to be configured based on the editing style. Functions
hooked to this hook takes the current style as parameter, this
basically generalize the hook used to setup hjkl navigation bindings.
- ESC has been removed from the emacs state map.
- Revert unneeded changes
- Revert "evil: enter insert-state only from normal-state"
commit bdd702dfbe302206bbc989c7a0832daba087a781.
- Revert "avoid being evil in deft with emacs editing style"
commit f3a16f49ed27cc8cf05f23f93b006d6e04235381.
Additional changes
All editing style packages have been moved to a layer called
`spacemacs-editing-styles`
Notes
I did not have time to attack hybrid mode, I should be able to do it
later.
2016-03-13 23:41:18 +00:00
|
|
|
(evil-insert-state))
|
2016-01-21 16:50:51 +00:00
|
|
|
|
|
|
|
(defun spacemacs/skewer-eval-region (beg end)
|
|
|
|
"Execute the region as JavaScript code in the attached browser."
|
|
|
|
(interactive "r")
|
|
|
|
(skewer-eval (buffer-substring beg end) #'skewer-post-minibuffer))
|
|
|
|
|
|
|
|
(defun spacemacs/skewer-eval-region-and-focus (beg end)
|
|
|
|
"Execute the region in browser and swith to REPL in insert state."
|
|
|
|
(interactive "r")
|
|
|
|
(spacemacs/skewer-eval-region beg end)
|
|
|
|
(skewer-repl)
|
Use evil in holy-mode
Motivation
While disabling Evil in holy-mode makes its implementation shorter and
sounds elegant on the paper, in practice it puts a big burden on the
configuration parts which need to know if Evil is enable or not. This is
a bad separation of concerns and the bunch of fixes that we were forced
to do in the past weeks shows this issue. Those fixes were about
removing the knowledge of the activation of Evil by implementing new
dispatching functions to be used by layers, this is cumbersome and makes
Spacemacs layer configuration more subtle which is not good. There was
additional bad consequences of the removal of Evil state like the
impossibility to use Evil lisp state or iedit states, or we would have
been forced to implement a temporary activation of Evil which is
awkward.
Instead I reintroduce Evil as the central piece of Spacemacs design thus
Evil is now re-enabled in holy-mode. It provides the abstraction we need
to isolate editing styles and be able to grow the Spacemacs
configuration coverage sanely. Layers don't need to check whether the
holy mode is active or not and they don't need to know if Evil is
available (it is always available). We also don't need to write
additional dispatching functions, this is the job of Evil, and I think
it provides everything for this. Ideally configuration layer should be
implemented with only Evil in mind and the holy-mode (and hybrid-mode)
should magically make it work for Emacs style users, for instance we can
freely use `evil-insert-state` anywhere in the code without any guard.
Evil is now even more part of Spacemacs, we can really say that
Spacemacs is Emacs+Evil which is now an indivisible pair. Spacemacs
needed this stable API to continue on the right track.
While these changes should be rather transparent to the user, I'm sorry
for this experimental period, I failed to see all the implications of
such a change, I was just excited about the possibility to make Evil
optional. The reality is that Spacemacs has to embrace it and keep its
strong position on being Emacs+Evil at the core.
Implementation
- insert, motion and normal states are forced to emacs state using an
advice on `evil-insert-state`, `evil-motion-state` and
`evil-normal-state` respectively. These functions can be used freely in
the layer configuration.
- A new general hook `spacemacs-editing-style-hook` allow to hook any
code that need to be configured based on the editing style. Functions
hooked to this hook takes the current style as parameter, this
basically generalize the hook used to setup hjkl navigation bindings.
- ESC has been removed from the emacs state map.
- Revert unneeded changes
- Revert "evil: enter insert-state only from normal-state"
commit bdd702dfbe302206bbc989c7a0832daba087a781.
- Revert "avoid being evil in deft with emacs editing style"
commit f3a16f49ed27cc8cf05f23f93b006d6e04235381.
Additional changes
All editing style packages have been moved to a layer called
`spacemacs-editing-styles`
Notes
I did not have time to attack hybrid mode, I should be able to do it
later.
2016-03-13 23:41:18 +00:00
|
|
|
(evil-insert-state))
|
2016-01-21 16:50:51 +00:00
|
|
|
|
2016-08-31 07:37:08 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode 'js2-mode "ms" "skewer")
|
|
|
|
(spacemacs/declare-prefix-for-mode 'js2-mode "me" "eval")
|
2016-01-21 16:50:51 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'js2-mode
|
2016-01-26 16:31:15 +00:00
|
|
|
"'" 'spacemacs/skewer-start-repl
|
2016-01-21 16:50:51 +00:00
|
|
|
"ee" 'skewer-eval-last-expression
|
|
|
|
"eE" 'skewer-eval-print-last-expression
|
|
|
|
"sb" 'skewer-load-buffer
|
|
|
|
"sB" 'spacemacs/skewer-load-buffer-and-focus
|
|
|
|
"si" 'spacemacs/skewer-start-repl
|
|
|
|
"sf" 'skewer-eval-defun
|
|
|
|
"sF" 'spacemacs/skewer-eval-defun-and-focus
|
|
|
|
"sr" 'spacemacs/skewer-eval-region
|
|
|
|
"sR" 'spacemacs/skewer-eval-region-and-focus
|
|
|
|
"ss" 'skewer-repl))))
|
2015-09-11 02:41:50 +00:00
|
|
|
|
|
|
|
(defun javascript/init-livid-mode ()
|
|
|
|
(use-package livid-mode
|
|
|
|
:defer t
|
2016-01-21 16:50:51 +00:00
|
|
|
:init (spacemacs|add-toggle javascript-repl-live-evaluation
|
2016-05-31 13:11:00 +00:00
|
|
|
:mode livid-mode
|
2016-01-21 16:50:51 +00:00
|
|
|
:documentation "Live evaluation of JS buffer change."
|
|
|
|
:evil-leader-for-mode (js2-mode . "sa"))))
|