From f667a0e02ac5781a7b7e640b5dc9a7edcf2f4a0b Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 26 Aug 2019 19:49:40 -0400 Subject: [PATCH 1/2] vim-patch:8.1.1930: cannot recognize .jsx and .tsx files Problem: Cannot recognize .jsx and .tsx files. Solution: Recognize them as javascriptreact and typescriptreact. (closes vim/vim#4830) https://github.com/vim/vim/commit/92852cee3fcff1dc6ce12387b234634e73267b22 --- runtime/filetype.vim | 8 +++++++- runtime/ftplugin/javascriptreact.vim | 2 ++ runtime/indent/javascriptreact.vim | 2 ++ runtime/syntax/javascriptreact.vim | 2 ++ src/nvim/testdir/test_filetype.vim | 6 ++++-- 5 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 runtime/ftplugin/javascriptreact.vim create mode 100644 runtime/indent/javascriptreact.vim create mode 100644 runtime/syntax/javascriptreact.vim diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 4cc2f49a63..43e96f2049 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -791,7 +791,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 @@ -1705,6 +1708,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 index 0000000000..ea5c9f5d99 --- /dev/null +++ b/runtime/ftplugin/javascriptreact.vim @@ -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 index 0000000000..ea5c9f5d99 --- /dev/null +++ b/runtime/indent/javascriptreact.vim @@ -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 index 0000000000..ea5c9f5d99 --- /dev/null +++ b/runtime/syntax/javascriptreact.vim @@ -0,0 +1,2 @@ +" Placeholder for backwards compatilibity: .jsx used to stand for JavaScript. +source %:h/javascript.vim diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim index a9ade9155a..7512d599b8 100644 --- a/src/nvim/testdir/test_filetype.vim +++ b/src/nvim/testdir/test_filetype.vim @@ -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'], @@ -454,6 +455,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'], @@ -608,5 +610,5 @@ endfunc func Test_setfiletype_completion() call feedkeys(":setfiletype java\\\"\", 'tx') - call assert_equal('"setfiletype java javacc javascript', @:) + call assert_equal('"setfiletype java javacc javascript javascriptreact', @:) endfunc From 41ec296640fe286541a9a842e463abbb475e0a03 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 26 Aug 2019 19:51:35 -0400 Subject: [PATCH 2/2] vim-patch:8.1.1931: syntax test fails Problem: Syntax test fails. Solution: Add new javascriptreact type to completions. https://github.com/vim/vim/commit/ea7a08a53ea0e8b4fe1592d9ae4d8f581fef46f8 --- src/nvim/testdir/test_syntax.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nvim/testdir/test_syntax.vim b/src/nvim/testdir/test_syntax.vim index fc0dc6693c..d6b2a53727 100644 --- a/src/nvim/testdir/test_syntax.vim +++ b/src/nvim/testdir/test_syntax.vim @@ -389,7 +389,7 @@ endfunc func Test_ownsyntax_completion() call feedkeys(":ownsyntax java\\\"\", 'tx') - call assert_equal('"ownsyntax java javacc javascript', @:) + call assert_equal('"ownsyntax java javacc javascript javascriptreact', @:) endfunc func Test_highlight_invalid_arg()