File tree 1 file changed +11
-1
lines changed
1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -23,10 +23,20 @@ if g:jsx_pragma_required
23
23
let b: jsx_pragma_found = search (s: jsx_pragma_pattern , ' npw' )
24
24
endif
25
25
26
+ " if g:jsx_check_react_import == 1
27
+ " parse the first line of js file (skipping comments). When it has a 'react'
28
+ " importation, we guess the user writes jsx
29
+ " endif
30
+ let s: jsx_prevalent_pattern =
31
+ \ ' \v\C%^\_s*%(%(//.*\_$|/\*\_.{-}\*/)@>\_s*)*%(import\s+\k+\s+from\s+|%(\l+\s+)=\k+\s*\=\s*require\s*\(\s*)[`"'' ]react>'
32
+
26
33
" Whether to set the JSX filetype on *.js files.
27
34
fu ! <SID> EnableJSX ()
28
35
if g: jsx_pragma_required && ! b: jsx_pragma_found | return 0 | endif
29
- if g: jsx_ext_required && ! exists (' b:jsx_ext_found' ) | return 0 | endif
36
+ if g: jsx_ext_required && ! exists (' b:jsx_ext_found' ) &&
37
+ \ ! (get (g: ,' jsx_check_react_import' ) && search (s: jsx_prevalent_pattern , ' nw' ))
38
+ return 0
39
+ endif
30
40
return 1
31
41
endfu
32
42
You can’t perform that action at this time.
0 commit comments