react: make react layer depends on new tern layer

This commit is contained in:
syl20bnr 2018-05-18 00:16:43 -04:00
parent 8616f07b86
commit c15b65435e
3 changed files with 7 additions and 19 deletions

View file

@ -24,31 +24,15 @@
(defun spacemacs//react-setup-backend () (defun spacemacs//react-setup-backend ()
"Conditionally setup react backend." "Conditionally setup react backend."
(pcase javascript-backend (pcase javascript-backend
(`tern(spacemacs//react-setup-tern)) (`tern (spacemacs/tern-setup-tern))
(`lsp (spacemacs//react-setup-lsp)))) (`lsp (spacemacs//react-setup-lsp))))
(defun spacemacs//react-setup-company () (defun spacemacs//react-setup-company ()
"Conditionally setup company based on backend." "Conditionally setup company based on backend."
(pcase javascript-backend (pcase javascript-backend
(`tern (spacemacs//react-setup-tern-company)) (`tern (spacemacs/tern-setup-tern-company 'rjsx-mode))
(`lsp (spacemacs//react-setup-lsp-company)))) (`lsp (spacemacs//react-setup-lsp-company))))
;; Tern
(defun spacemacs//react-setup-tern ()
"Setup tern backend."
(tern-mode)
(spacemacs//set-tern-key-bindings 'rjsx-mode))
(defun spacemacs//react-setup-tern-company ()
"Setup tern auto-completion."
(spacemacs|add-company-backends
:backends company-tern
:modes rjsx-mode
:append-hooks nil
:call-hooks t)
(company-mode))
;; LSP ;; LSP
(defun spacemacs//react-setup-lsp () (defun spacemacs//react-setup-lsp ()

View file

@ -9,4 +9,4 @@
;; ;;
;;; License: GPLv3 ;;; License: GPLv3
(configuration-layer/declare-layers '(javascript)) (configuration-layer/declare-layers '(javascript tern))

View file

@ -19,6 +19,7 @@
js-doc js-doc
rjsx-mode rjsx-mode
smartparens smartparens
tern
web-beautify web-beautify
)) ))
@ -83,5 +84,8 @@
(add-hook 'react-mode-hook #'smartparens-strict-mode) (add-hook 'react-mode-hook #'smartparens-strict-mode)
(add-hook 'react-mode-hook #'smartparens-mode))) (add-hook 'react-mode-hook #'smartparens-mode)))
(defun react/post-init-tern ()
(add-to-list 'tern--key-bindings-modes 'rjsx-mode))
(defun react/post-init-web-beautify () (defun react/post-init-web-beautify ()
(spacemacs/set-leader-keys-for-major-mode 'react-mode "=" 'web-beautify-js)) (spacemacs/set-leader-keys-for-major-mode 'react-mode "=" 'web-beautify-js))