aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-01-01 21:45:12 +0800
committerGitHub <noreply@github.com>2023-01-01 21:45:12 +0800
commit83e8723864e24d9bf542e779d9612d3ffd014dbf (patch)
tree5d29a292201ae7b2f46ae0d449c7c1559e377117 /src
parent6ba34e21fee2a81677e8261dfeaf24c8cd320500 (diff)
parent85b7c8b004a36a15731a461e5e95f2c9fca732f1 (diff)
downloadrneovim-83e8723864e24d9bf542e779d9612d3ffd014dbf.tar.gz
rneovim-83e8723864e24d9bf542e779d9612d3ffd014dbf.tar.bz2
rneovim-83e8723864e24d9bf542e779d9612d3ffd014dbf.zip
Merge pull request #21597 from gi1242/tex-ft-detection
fix(filetype): make .tex filetype detection match Vim
Diffstat (limited to 'src')
-rw-r--r--src/nvim/testdir/test_filetype.vim38
1 files changed, 33 insertions, 5 deletions
diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim
index cf155b3cb9..912e702631 100644
--- a/src/nvim/testdir/test_filetype.vim
+++ b/src/nvim/testdir/test_filetype.vim
@@ -1676,16 +1676,44 @@ endfunc
func Test_tex_file()
filetype on
- " only tests one case, should do more
+ call writefile(['%& pdflatex'], 'Xfile.tex')
+ split Xfile.tex
+ call assert_equal('tex', &filetype)
+ bwipe
+
+ call writefile(['\newcommand{\test}{some text}'], 'Xfile.tex')
+ split Xfile.tex
+ call assert_equal('tex', &filetype)
+ bwipe
+
+ " tex_flavor is unset
+ call writefile(['%& plain'], 'Xfile.tex')
+ split Xfile.tex
+ call assert_equal('plaintex', &filetype)
+ bwipe
+
+ let g:tex_flavor = 'plain'
+ call writefile(['just some text'], 'Xfile.tex')
+ split Xfile.tex
+ call assert_equal('plaintex', &filetype)
+ bwipe
+
let lines =<< trim END
- % This is a sentence.
+ % This is a comment.
- This is a sentence.
+ \usemodule[translate]
END
- call writefile(lines, "Xfile.tex")
+ call writefile(lines, 'Xfile.tex')
split Xfile.tex
- call assert_equal('plaintex', &filetype)
+ call assert_equal('context', &filetype)
+ bwipe
+
+ let g:tex_flavor = 'context'
+ call writefile(['just some text'], 'Xfile.tex')
+ split Xfile.tex
+ call assert_equal('context', &filetype)
bwipe
+ unlet g:tex_flavor
call delete('Xfile.tex')
filetype off