lang/javascript: more intelligent JSX detection

This commit is contained in:
Henrik Lissner 2017-04-04 03:36:21 -04:00
parent cfc52a8d40
commit a0ae976555

View file

@ -104,6 +104,18 @@
:commands rjsx-mode
:mode "\\.jsx$"
:mode "components/.+\\.js$"
:init
;; auto-detect JSX file
(push (cons (lambda ()
(and (equal (file-name-extension buffer-file-name) "js")
(re-search-forward "\\(^\\s-*import React\\|\\( from \\|require(\\)[\"']react\\)"
magic-mode-regexp-match-limit t)
(progn
(goto-char (match-beginning 1))
(not (sp-point-in-string-or-comment)))))
'rjsx-mode)
magic-mode-alist)
:config
;; disable electric keys (I use snippets and `emmet-mode' instead)
(define-key rjsx-mode-map "<" nil)