summaryrefslogtreecommitdiff
path: root/runtime/filetype.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2005-06-30 22:04:15 +0000
committerBram Moolenaar <Bram@vim.org>2005-06-30 22:04:15 +0000
commitd042c56e34b5c032e79fa1fee19ce6d16ac99e49 (patch)
tree4a8b46e7449632fadf17aa764ae4eb60ad749459 /runtime/filetype.vim
parente6b165e0f4f70d22a4fbcc5c9a1818417bdb1b04 (diff)
downloadvim-git-d042c56e34b5c032e79fa1fee19ce6d16ac99e49.tar.gz
updated for version 7.0098
Diffstat (limited to 'runtime/filetype.vim')
-rw-r--r--runtime/filetype.vim26
1 files changed, 23 insertions, 3 deletions
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index 9b47dca67..c11c012c3 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -1,7 +1,7 @@
" Vim support file to detect file types
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2005 Jun 29
+" Last Change: 2005 Jun 30
" Listen very carefully, I will say this only once
if exists("did_load_filetypes")
@@ -1585,7 +1585,27 @@ au BufNewFile,BufRead *.slt setf tsalt
au BufNewFile,BufRead *.ti setf terminfo
" TeX
-au BufNewFile,BufRead *.tex,*.latex,*.sty,*.dtx,*.ltx,*.bbl setf tex
+au BufNewFile,BufRead *.latex,*.sty,*.dtx,*.ltx,*.bbl setf tex
+au BufNewFile,BufRead *.tex call s:FTtex()
+
+fun! s:FTtex()
+ let n = 1
+ while n < 10 && n < line("$")
+ let line = getline(n)
+ if line =~ '^\s*\\\%(documentclass\>\|usepackage\>\|begin{\)'
+ setf tex
+ return
+ elseif line =~ '^\s*\\\%(start\l\+\|setup\l\+\|usemodule\)\>'
+ setf context
+ return
+ endif
+ let n = n + 1
+ endwhile
+ setf tex
+endfun
+
+" Context
+au BufNewFile,BufRead tex/context/*/*.tex setf context
" Texinfo
au BufNewFile,BufRead *.texinfo,*.texi,*.txi setf texinfo
@@ -1746,7 +1766,7 @@ au BufNewFile,BufRead *.y call s:FTy()
fun! s:FTy()
let n = 1
- while n < 10
+ while n < 10 && n < line("$")
if getline(n) =~ '^\s*\(#\|class\>\)'
setf racc
return