]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0289: filetype: some TeX files are not recognized v9.1.0289
authorWu, Zhenyu <wuzhenyu@ustc.edu>
Tue, 9 Apr 2024 20:09:30 +0000 (22:09 +0200)
committerChristian Brabandt <cb@256bit.org>
Tue, 9 Apr 2024 20:09:30 +0000 (22:09 +0200)
Problem:  filetype: some TeX files are not recognized
Solution: Add more patterns for TeX files and inspect
          a few more files for being TeX files
          (Wu, Zhenyu)

closes: #14456

Signed-off-by: Wu, Zhenyu <wuzhenyu@ustc.edu>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/autoload/dist/ft.vim
runtime/filetype.vim
src/testdir/test_filetype.vim
src/version.c

index 14628308eee7478c9bc94744f1fef254a1bfeb16..05f1611b220294891f662fbf452d70bc80388ef8 100644 (file)
@@ -10,7 +10,9 @@ vim9script
 # faster.
 
 export def Check_inp()
-  if getline(1) =~ '^\*'
+  if getline(1) =~ '%%'
+    setf tex
+  elseif getline(1) =~ '^\*'
     setf abaqus
   else
     var n = 1
@@ -280,6 +282,10 @@ export def DtraceCheck()
 enddef
 
 export def FTdef()
+  # LaTeX def files are usually generated by docstrip, which will output '%%' in first line
+  if getline(1) =~ '%%'
+    setf tex
+  endif
   if get(g:, "filetype_def", "") == "modula2" || IsModula2()
     SetFiletypeModula2()
     return
index 911ca1ee3a9b1f9cf4715bfceb4d14f9a11c19d7..51630d20e2237adc9da444c0953639a4d0c95d98 100644 (file)
@@ -305,8 +305,9 @@ au BufNewFile,BufRead *.csdl                        setf csdl
 " Cabal
 au BufNewFile,BufRead *.cabal                  setf cabal
 
-" Cdrdao TOC
-au BufNewFile,BufRead *.toc                    setf cdrtoc
+" Cdrdao TOC or LaTeX \tableofcontents files
+au BufNewFile,BufRead *.toc
+       \ if getline(1) =~# '\\contentsline' |setf tex|else|setf cdrtoc|endif
 
 " Cdrdao config
 au BufNewFile,BufRead */etc/cdrdao.conf,*/etc/defaults/cdrdao,*/etc/default/cdrdao,.cdrdao     setf cdrdaoconf
@@ -1258,7 +1259,11 @@ au BufNewFile,BufRead */etc/login.defs           setf logindefs
 au BufNewFile,BufRead *.lgt                    setf logtalk
 
 " LOTOS
-au BufNewFile,BufRead *.lot,*.lotos            setf lotos
+au BufNewFile,BufRead *.lotos          setf lotos
+
+" LOTOS or LaTeX \listoftables files
+au BufNewFile,BufRead *.lot
+       \ if getline(1) =~# '\\contentsline' |setf tex|else|setf lotos|endif
 
 " Lout (also: *.lt)
 au BufNewFile,BufRead *.lou,*.lout             setf lout
@@ -2313,6 +2318,16 @@ au BufRead,BufNewFile *.tfvars                   setf terraform-vars
 au BufNewFile,BufRead *.latex,*.sty,*.dtx,*.ltx,*.bbl  setf tex
 au BufNewFile,BufRead *.tex                    call dist#ft#FTtex()
 
+" LaTeX packages use LaTeX as their configuration, such as:
+" ~/.texlive/texmf-config/tex/latex/hyperref/hyperref.cfg
+" ~/.texlive/texmf-config/tex/latex/docstrip/docstrip.cfg
+au BufNewFile,BufRead */tex/latex/**.cfg               setf tex
+
+" LaTeX packages will generate some medium LaTeX files during compiling
+" They should be ignored by .gitignore https://github.com/github/gitignore/blob/main/TeX.gitignore
+" Sometime we need to view its content for debugging
+au BufNewFile,BufRead *.{pgf,nlo,nls,out,thm,eps_tex,pygtex,pygstyle,clo,aux,brf,ind,lof,loe,nav,vrb,ins,tikz,bbx,cbx,beamer}  setf tex
+
 " ConTeXt
 au BufNewFile,BufRead *.mkii,*.mkiv,*.mkvi,*.mkxl,*.mklx   setf context
 
index 19c8a2afe74cb1fcb5a463ce3ca6862cfbfa0593..8417eaee84cbbae3b8dc9187c79d8b1b5234da0f 100644 (file)
@@ -735,7 +735,7 @@ def s:GetFilenameChecks(): dict<list<string>>
     teraterm: ['file.ttl'],
     terminfo: ['file.ti'],
     'terraform-vars': ['file.tfvars'],
-    tex: ['file.latex', 'file.sty', 'file.dtx', 'file.ltx', 'file.bbl'],
+    tex: ['file.latex', 'file.sty', 'file.dtx', 'file.ltx', 'file.bbl', 'any/.texlive/texmf-config/tex/latex/file/file.cfg', 'file.pgf', 'file.nlo', 'file.nls', 'file.out', 'file.thm', 'file.eps_tex', 'file.pygtex', 'file.pygstyle', 'file.clo', 'file.aux', 'file.brf', 'file.ind', 'file.lof', 'file.loe', 'file.nav', 'file.vrb', 'file.ins', 'file.tikz', 'file.bbx', 'file.cbx', 'file.beamer'],
     texinfo: ['file.texinfo', 'file.texi', 'file.txi'],
     texmf: ['texmf.cnf'],
     text: ['file.text', 'file.txt', 'README', 'LICENSE', 'COPYING', 'AUTHORS', '/usr/share/doc/bash-completion/AUTHORS', '/etc/apt/apt.conf.d/README', '/etc/Muttrc.d/README'],
index 44f99236748e9a641a494a56e6a843563c3bfc5f..f1c52c5ae756f4f49ae1bd92dfe46677c80e79f4 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    289,
 /**/
     288,
 /**/