blob: b392fa27883b8fedba4a3cec77c3827ee6daac1a [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" LaTeX filetype plugin
2" Language: LaTeX (ft=tex)
3" Maintainer: Benji Fisher, Ph.D. <benji@member.AMS.org>
Bram Moolenaarc01140a2006-03-24 22:21:52 +00004" Version: 1.3
5" Last Change: Wed 22 Mar 2006 09:36:32 AM EST
Bram Moolenaar071d4272004-06-13 20:20:40 +00006" URL: http://www.vim.org/script.php?script_id=411
7
Bram Moolenaarc01140a2006-03-24 22:21:52 +00008" Only do this when not done yet for this buffer.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009if exists("b:did_ftplugin")
10 finish
11endif
12
Bram Moolenaarc01140a2006-03-24 22:21:52 +000013" Start with plain TeX. This will also define b:did_ftplugin .
14source $VIMRUNTIME/ftplugin/plaintex.vim
Bram Moolenaar071d4272004-06-13 20:20:40 +000015
Bram Moolenaarc01140a2006-03-24 22:21:52 +000016" Avoid problems if running in 'compatible' mode.
Bram Moolenaar071d4272004-06-13 20:20:40 +000017let s:save_cpo = &cpo
18set cpo&vim
19
Bram Moolenaar071d4272004-06-13 20:20:40 +000020" Allow "[d" to be used to find a macro definition:
21" Recognize plain TeX \def as well as LaTeX \newcommand and \renewcommand .
22" I may as well add the AMS-LaTeX DeclareMathOperator as well.
Bram Moolenaarc01140a2006-03-24 22:21:52 +000023let &l:define .= '\|\\\(re\)\=new\(boolean\|command\|counter\|environment\|font'
Bram Moolenaar071d4272004-06-13 20:20:40 +000024 \ . '\|if\|length\|savebox\|theorem\(style\)\=\)\s*\*\=\s*{\='
25 \ . '\|DeclareMathOperator\s*{\=\s*'
26
27" Tell Vim how to recognize LaTeX \include{foo} and plain \input bar :
Bram Moolenaarc01140a2006-03-24 22:21:52 +000028let &l:include .= '\|\\include{'
Bram Moolenaar071d4272004-06-13 20:20:40 +000029" On some file systems, "{" and "}" are inluded in 'isfname'. In case the
30" TeX file has \include{fname} (LaTeX only), strip everything except "fname".
31let &l:includeexpr = "substitute(v:fname, '^.\\{-}{\\|}.*', '', 'g')"
Bram Moolenaar071d4272004-06-13 20:20:40 +000032
33" The following lines enable the macros/matchit.vim plugin for
34" extended matching with the % key.
Bram Moolenaarc01140a2006-03-24 22:21:52 +000035" ftplugin/plaintex.vim already defines b:match_skip and b:match_ignorecase
36" and matches \(, \), \[, and \].
Bram Moolenaar071d4272004-06-13 20:20:40 +000037if exists("loaded_matchit")
Bram Moolenaarc01140a2006-03-24 22:21:52 +000038 let b:match_words .= '\\begin\s*\({\a\+\*\=}\):\\end\s*\1'
Bram Moolenaar071d4272004-06-13 20:20:40 +000039endif " exists("loaded_matchit")
40
41let &cpo = s:save_cpo
42
43" vim:sts=2:sw=2: