lang/javascript: more intelligent JSX detection
This commit is contained in:
parent
cfc52a8d40
commit
a0ae976555
1 changed files with 12 additions and 0 deletions
|
@ -104,6 +104,18 @@
|
||||||
:commands rjsx-mode
|
:commands rjsx-mode
|
||||||
:mode "\\.jsx$"
|
:mode "\\.jsx$"
|
||||||
:mode "components/.+\\.js$"
|
: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
|
:config
|
||||||
;; disable electric keys (I use snippets and `emmet-mode' instead)
|
;; disable electric keys (I use snippets and `emmet-mode' instead)
|
||||||
(define-key rjsx-mode-map "<" nil)
|
(define-key rjsx-mode-map "<" nil)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue