2015-07-24 20:07:03 +00:00
|
|
|
;;; packages.el --- react Layer packages File for Spacemacs
|
|
|
|
;;
|
2016-01-12 02:40:54 +00:00
|
|
|
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
|
2015-07-24 20:07:03 +00:00
|
|
|
;;
|
|
|
|
;; Author: Andrea Moretti <axyzxp@gmail.com>
|
|
|
|
;; URL: https://github.com/axyz
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
|
|
|
(setq react-packages
|
2015-07-28 22:05:16 +00:00
|
|
|
'(
|
2015-08-25 01:37:42 +00:00
|
|
|
company
|
|
|
|
company-tern
|
2016-02-28 08:15:24 +00:00
|
|
|
evil-matchit
|
2015-08-25 01:37:42 +00:00
|
|
|
flycheck
|
|
|
|
js-doc
|
2015-07-28 22:05:16 +00:00
|
|
|
js2-mode
|
|
|
|
js2-refactor
|
2015-08-27 03:04:53 +00:00
|
|
|
tern
|
2015-07-28 22:05:16 +00:00
|
|
|
web-beautify
|
2015-08-25 01:37:42 +00:00
|
|
|
web-mode
|
2015-07-28 22:05:16 +00:00
|
|
|
))
|
2015-07-24 20:07:03 +00:00
|
|
|
|
2015-08-25 01:37:42 +00:00
|
|
|
(when (configuration-layer/layer-usedp 'auto-completion)
|
|
|
|
(defun react/post-init-company ()
|
|
|
|
(spacemacs|add-company-hook react-mode))
|
|
|
|
|
2015-08-26 00:57:56 +00:00
|
|
|
(defun react/post-init-company-tern ()
|
|
|
|
(push 'company-tern company-backends-react-mode)))
|
2015-07-24 20:07:03 +00:00
|
|
|
|
2016-02-28 08:15:24 +00:00
|
|
|
(defun react/post-init-evil-matchit ()
|
|
|
|
(with-eval-after-load 'evil-matchit
|
|
|
|
(plist-put evilmi-plugins 'react-mode '((evilmi-simple-get-tag evilmi-simple-jump)
|
|
|
|
(evilmi-javascript-get-tag evilmi-javascript-jump)
|
|
|
|
(evilmi-html-get-tag evilmi-html-jump)))))
|
|
|
|
|
2015-08-26 00:57:56 +00:00
|
|
|
(defun react/pre-init-flycheck ()
|
|
|
|
(spacemacs|use-package-add-hook flycheck
|
|
|
|
:post-config
|
2015-07-27 22:26:47 +00:00
|
|
|
(progn
|
2015-08-26 00:57:56 +00:00
|
|
|
(flycheck-add-mode 'javascript-eslint 'react-mode)
|
2015-11-13 10:04:02 +00:00
|
|
|
|
|
|
|
(defun react/disable-jshint ()
|
|
|
|
(push 'javascript-jshint flycheck-disabled-checkers))
|
|
|
|
|
|
|
|
(add-hook 'react-mode-hook #'react/disable-jshint))))
|
2015-07-27 22:26:47 +00:00
|
|
|
|
2015-08-26 00:57:56 +00:00
|
|
|
(defun react/post-init-flycheck ()
|
2016-01-27 20:08:25 +00:00
|
|
|
(spacemacs/add-flycheck-hook 'react-mode))
|
2015-07-27 22:26:47 +00:00
|
|
|
|
2015-08-26 00:57:56 +00:00
|
|
|
(defun react/post-init-js-doc ()
|
|
|
|
(add-hook 'react-mode-hook 'spacemacs/js-doc-require)
|
|
|
|
(spacemacs/js-doc-set-key-bindings 'react-mode))
|
2015-07-27 22:26:47 +00:00
|
|
|
|
2015-08-26 00:57:56 +00:00
|
|
|
(defun react/post-init-js2-mode ()
|
|
|
|
(add-hook 'react-mode-hook 'js2-imenu-extras-mode)
|
|
|
|
(add-hook 'react-mode-hook 'js2-minor-mode))
|
2015-07-28 22:05:16 +00:00
|
|
|
|
2015-08-26 00:57:56 +00:00
|
|
|
(defun react/post-init-js2-refactor ()
|
|
|
|
(add-hook 'react-mode-hook 'spacemacs/js2-refactor-require)
|
|
|
|
(spacemacs/js2-refactor-set-key-bindings 'react-mode))
|
2015-07-28 22:05:16 +00:00
|
|
|
|
2015-08-27 03:04:53 +00:00
|
|
|
(defun react/post-init-tern ()
|
|
|
|
(add-hook 'react-mode-hook 'tern-mode))
|
|
|
|
|
2015-08-26 00:57:56 +00:00
|
|
|
(defun react/post-init-web-beautify ()
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'react-mode "=" 'web-beautify-js))
|
2015-07-28 22:05:16 +00:00
|
|
|
|
2015-08-25 01:37:42 +00:00
|
|
|
(defun react/post-init-web-mode ()
|
|
|
|
(define-derived-mode react-mode web-mode "react")
|
|
|
|
(add-to-list 'auto-mode-alist '("\\.jsx\\'" . react-mode))
|
|
|
|
(add-to-list 'auto-mode-alist '("\\.react.js\\'" . react-mode))
|
2015-12-22 09:34:58 +00:00
|
|
|
(add-to-list 'auto-mode-alist '("\\index.android.js\\'" . react-mode))
|
|
|
|
(add-to-list 'auto-mode-alist '("\\index.ios.js\\'" . react-mode))
|
2016-02-08 14:54:28 +00:00
|
|
|
(add-to-list 'magic-mode-alist '("/\\*\\* @jsx React\\.DOM \\*/" . react-mode))
|
2015-08-26 00:57:56 +00:00
|
|
|
(defun spacemacs//setup-react-mode ()
|
|
|
|
"Adjust web-mode to accommodate react-mode"
|
|
|
|
(emmet-mode 0)
|
2015-10-09 06:30:56 +00:00
|
|
|
;; See https://github.com/CestDiego/emmet-mode/commit/3f2904196e856d31b9c95794d2682c4c7365db23
|
|
|
|
(setq-local emmet-expand-jsx-className? t)
|
2015-12-01 08:07:19 +00:00
|
|
|
;; Enable js-mode snippets
|
|
|
|
(yas-activate-extra-mode 'js-mode)
|
2015-09-29 02:03:10 +00:00
|
|
|
;; Force jsx content type
|
|
|
|
(web-mode-set-content-type "jsx")
|
2016-01-22 08:34:12 +00:00
|
|
|
;; Don't auto-quote attribute values
|
|
|
|
(setq-local web-mode-enable-auto-quoting nil)
|
2015-08-26 00:57:56 +00:00
|
|
|
;; Why do we do this ?
|
|
|
|
(defadvice web-mode-highlight-part (around tweak-jsx activate)
|
|
|
|
(let ((web-mode-enable-part-face nil))
|
|
|
|
ad-do-it)))
|
|
|
|
(add-hook 'react-mode-hook 'spacemacs//setup-react-mode))
|