mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-01 12:17:25 -05:00
lang/javascript: more intelligent JSX detection
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user