Skip to content

Commit

Permalink
Fix flow-type errors when react layer isn't installed
Browse files Browse the repository at this point in the history
  • Loading branch information
jdelStrother committed Oct 10, 2016
1 parent 15efa7e commit 6dcf42a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
3 changes: 1 addition & 2 deletions layers/+lang/flow-type/README.org
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ This layer adds some [[https://flowtype.org/][flow]] related functionality to Em
* Install
To use this configuration layer, add it to your =~/.spacemacs=. You will need to
add =flow-type= to the existing =dotspacemacs-configuration-layers= list in this
file.

file. Please ensure you already have the flow binary installed and in your PATH.
2 changes: 1 addition & 1 deletion layers/+lang/flow-type/funcs.el
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
(unless (string-match "\w*flow is still initializing" output)
(flow-type/type-description (json-read-from-string output)))))

(defun flow-type/init-mode ()
(defun flow-type/enable-eldoc ()
(set (make-local-variable 'eldoc-documentation-function) 'flow-type/type-at-cursor))
20 changes: 10 additions & 10 deletions layers/+lang/flow-type/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
'(company
(company-flow :toggle (configuration-layer/package-usedp 'company))
(flycheck-flow :toggle (configuration-layer/package-usedp 'flycheck))
js2-mode
web-mode))
eldoc))

(defun flow-type/post-init-js2-mode()
(push 'flow-type/init-mode js2-mode-hook))

(defun flow-type/post-init-web-mode()
(push 'flow-type/init-mode react-mode-hook))
(defun flow-type/post-init-eldoc()
(when (configuration-layer/package-usedp 'js2-mode)
(push 'flow-type/enable-eldoc js2-mode-hook))
(when (configuration-layer/layer-usedp 'react)
(push 'flow-type/enable-eldoc react-mode-hook)))

(defun flow-type/post-init-company()
(spacemacs|add-company-hook js2-mode)
(when (configuration-layer/package-usedp 'js2-mode)
(spacemacs|add-company-hook js2-mode))
(when (configuration-layer/layer-usedp 'react)
(spacemacs|add-company-hook react-mode)))

Expand All @@ -33,11 +33,11 @@
:init
(progn
(push 'company-flow company-backends-js2-mode)
(when (configuration-layer/package-usedp 'web-mode)
(when (configuration-layer/layer-usedp 'react)
(push 'company-flow company-backends-react-mode))
)
:config
(when (configuration-layer/package-usedp 'web-mode)
(when (configuration-layer/layer-usedp 'react)
(push 'react-mode company-flow-modes)))
)

Expand Down

0 comments on commit 6dcf42a

Please sign in to comment.