blob: 0d68b51d469e720744280067b5e3a09fecb624d1 [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 Moolenaar8424a622006-04-19 21:23:36 +00004" Version: 1.4
5" Last Change: Wed 19 Apr 2006
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 Moolenaar8424a622006-04-19 21:23:36 +000020let b:undo_ftplugin .= "| setl inex<"
21
Bram Moolenaar071d4272004-06-13 20:20:40 +000022" Allow "[d" to be used to find a macro definition:
23" Recognize plain TeX \def as well as LaTeX \newcommand and \renewcommand .
24" I may as well add the AMS-LaTeX DeclareMathOperator as well.
Bram Moolenaarc01140a2006-03-24 22:21:52 +000025let &l:define .= '\|\\\(re\)\=new\(boolean\|command\|counter\|environment\|font'
Bram Moolenaar071d4272004-06-13 20:20:40 +000026 \ . '\|if\|length\|savebox\|theorem\(style\)\=\)\s*\*\=\s*{\='
27 \ . '\|DeclareMathOperator\s*{\=\s*'
28
29" Tell Vim how to recognize LaTeX \include{foo} and plain \input bar :
Bram Moolenaarc01140a2006-03-24 22:21:52 +000030let &l:include .= '\|\\include{'
Bram Moolenaar6c391a72021-09-09 21:55:11 +020031" On some file systems, "{" and "}" are included in 'isfname'. In case the
Bram Moolenaar071d4272004-06-13 20:20:40 +000032" TeX file has \include{fname} (LaTeX only), strip everything except "fname".
33let &l:includeexpr = "substitute(v:fname, '^.\\{-}{\\|}.*', '', 'g')"
Bram Moolenaar071d4272004-06-13 20:20:40 +000034
35" The following lines enable the macros/matchit.vim plugin for
36" extended matching with the % key.
Bram Moolenaarc01140a2006-03-24 22:21:52 +000037" ftplugin/plaintex.vim already defines b:match_skip and b:match_ignorecase
Bram Moolenaar8424a622006-04-19 21:23:36 +000038" and matches \(, \), \[, \], \{, and \} .
Bram Moolenaar071d4272004-06-13 20:20:40 +000039if exists("loaded_matchit")
Bram Moolenaar8424a622006-04-19 21:23:36 +000040 let b:match_words .= ',\\begin\s*\({\a\+\*\=}\):\\end\s*\1'
Bram Moolenaar071d4272004-06-13 20:20:40 +000041endif " exists("loaded_matchit")
42
43let &cpo = s:save_cpo
Bram Moolenaar84f72352012-03-11 15:57:40 +010044unlet s:save_cpo
Bram Moolenaar071d4272004-06-13 20:20:40 +000045
46" vim:sts=2:sw=2: