diff options
-rw-r--r-- | runtime/filetype.vim | 9 | ||||
-rw-r--r-- | src/nvim/testdir/test_filetype.vim | 18 |
2 files changed, 24 insertions, 3 deletions
diff --git a/runtime/filetype.vim b/runtime/filetype.vim index b9d2a43d5d..ed19fa1a43 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1768,8 +1768,13 @@ au BufNewFile,BufReadPost *.tutor setf tutor " TWIG files au BufNewFile,BufReadPost *.twig setf twig -" Typescript -au BufNewFile,BufReadPost *.ts setf typescript +" Typescript or Qt translation file (which is XML) +au BufNewFile,BufReadPost *.ts + \ if getline(1) =~ '<?xml' | + \ setf xml | + \ else | + \ setf typescript | + \ endif " TypeScript with React au BufNewFile,BufRead *.tsx setf typescriptreact diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim index 52b5884c8b..f3c3e085f6 100644 --- a/src/nvim/testdir/test_filetype.vim +++ b/src/nvim/testdir/test_filetype.vim @@ -471,7 +471,6 @@ let s:filename_checks = { \ 'tssgm': ['file.tssgm'], \ 'tssop': ['file.tssop'], \ 'twig': ['file.twig'], - \ 'typescript': ['file.ts'], \ 'typescriptreact': ['file.tsx'], \ 'uc': ['file.uc'], \ 'udevconf': ['/etc/udev/udev.conf'], @@ -668,5 +667,22 @@ func Test_hook_file() filetype off endfunc +func Test_ts_file() + filetype on + + call writefile(['<?xml version="1.0" encoding="utf-8"?>'], 'Xfile.ts') + split Xfile.ts + call assert_equal('xml', &filetype) + bwipe! + + call writefile(['// looks like Typescript'], 'Xfile.ts') + split Xfile.ts + call assert_equal('typescript', &filetype) + bwipe! + + call delete('Xfile.hook') + filetype off +endfunc + " vim: shiftwidth=2 sts=2 expandtab |