]> granicus.if.org Git - vim/commitdiff
patch 8.1.1930: cannot recognize .jsx and .tsx files v8.1.1930
authorBram Moolenaar <Bram@vim.org>
Mon, 26 Aug 2019 19:28:15 +0000 (21:28 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 26 Aug 2019 19:28:15 +0000 (21:28 +0200)
Problem:    Cannot recognize .jsx and .tsx files.
Solution:   Recognize them as javascriptreact and typescriptreact.
            (closes #4830)

runtime/filetype.vim
runtime/ftplugin/javascriptreact.vim [new file with mode: 0644]
runtime/indent/javascriptreact.vim [new file with mode: 0644]
runtime/syntax/javascriptreact.vim [new file with mode: 0644]
src/testdir/test_filetype.vim
src/version.c

index 895ac065a39c789c88ba11934edd6bbe11e65d03..e702be9947c0a8c90114bafed444c7cc76d17a91 100644 (file)
@@ -798,7 +798,10 @@ au BufNewFile,BufRead *.java,*.jav         setf java
 au BufNewFile,BufRead *.jj,*.jjt               setf javacc
 
 " JavaScript, ECMAScript
-au BufNewFile,BufRead *.js,*.javascript,*.es,*.jsx,*.mjs   setf javascript
+au BufNewFile,BufRead *.js,*.javascript,*.es,*.mjs   setf javascript
+
+" JavaScript with React
+au BufNewFile,BufRead *.jsx                    setf javascriptreact
 
 " Java Server Pages
 au BufNewFile,BufRead *.jsp                    setf jsp
@@ -1709,6 +1712,9 @@ au BufNewFile,BufReadPost *.twig          setf twig
 " Typescript
 au BufNewFile,BufReadPost *.ts                 setf typescript
 
+" TypeScript with React
+au BufNewFile,BufRead *.tsx                    setf typescriptreact
+
 " Motif UIT/UIL files
 au BufNewFile,BufRead *.uit,*.uil              setf uil
 
diff --git a/runtime/ftplugin/javascriptreact.vim b/runtime/ftplugin/javascriptreact.vim
new file mode 100644 (file)
index 0000000..ea5c9f5
--- /dev/null
@@ -0,0 +1,2 @@
+" Placeholder for backwards compatilibity: .jsx used to stand for JavaScript.
+source %:h/javascript.vim
diff --git a/runtime/indent/javascriptreact.vim b/runtime/indent/javascriptreact.vim
new file mode 100644 (file)
index 0000000..ea5c9f5
--- /dev/null
@@ -0,0 +1,2 @@
+" Placeholder for backwards compatilibity: .jsx used to stand for JavaScript.
+source %:h/javascript.vim
diff --git a/runtime/syntax/javascriptreact.vim b/runtime/syntax/javascriptreact.vim
new file mode 100644 (file)
index 0000000..ea5c9f5
--- /dev/null
@@ -0,0 +1,2 @@
+" Placeholder for backwards compatilibity: .jsx used to stand for JavaScript.
+source %:h/javascript.vim
index 92a52057328734bf9986fbdcf589f4a47559eebb..19fd19a9acc2a3a85e3aac6995f845141712e89e 100644 (file)
@@ -221,7 +221,8 @@ let s:filename_checks = {
     \ 'jam': ['file.jpl', 'file.jpr'],
     \ 'java': ['file.java', 'file.jav'],
     \ 'javacc': ['file.jj', 'file.jjt'],
-    \ 'javascript': ['file.js', 'file.javascript', 'file.es', 'file.jsx', 'file.mjs'],
+    \ 'javascript': ['file.js', 'file.javascript', 'file.es', 'file.mjs'],
+    \ 'javascriptreact': ['file.jsx'],
     \ 'jess': ['file.clp'],
     \ 'jgraph': ['file.jgr'],
     \ 'jovial': ['file.jov', 'file.j73', 'file.jovial'],
@@ -455,6 +456,7 @@ let s:filename_checks = {
     \ 'tssop': ['file.tssop'],
     \ 'twig': ['file.twig'],
     \ 'typescript': ['file.ts'],
+    \ 'typescriptreact': ['file.tsx'],
     \ 'uc': ['file.uc'],
     \ 'udevconf': ['/etc/udev/udev.conf'],
     \ 'udevperm': ['/etc/udev/permissions.d/file.permissions'],
@@ -609,5 +611,5 @@ endfunc
 
 func Test_setfiletype_completion()
   call feedkeys(":setfiletype java\<C-A>\<C-B>\"\<CR>", 'tx')
-  call assert_equal('"setfiletype java javacc javascript', @:)
+  call assert_equal('"setfiletype java javacc javascript javascriptreact', @:)
 endfunc
index 1e628fd74ef4a7b07f71ac2d04aaf97be18be4c8..f0e441a13257fd7719d2e88dd6d145917bef2e47 100644 (file)
@@ -761,6 +761,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1930,
 /**/
     1929,
 /**/