annotate runtime/indent/tex.vim @ 3877:cd6c420e31d6 v7.3.695

updated for version 7.3.695 Problem: Balloon cannot show multi-byte text. Solution: Properly deal with multi-byte characters. (Dominique Pelle)
author Bram Moolenaar <bram@vim.org>
date Sun, 21 Oct 2012 00:58:39 +0200
parents 2cfb68fa26cd
children eb6ab7e78925
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1 " Vim indent file
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2 " Language: LaTeX
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
3 " Maintainer: Zhou YiChao <broken.zhou AT gmail.com>
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4 " Created: Sat, 16 Feb 2002 16:50:19 +0100
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
5 " Last Change: 2012 Mar 18 19:19:50
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
6 " Version: 0.7
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
7 " Please email me if you found something we can do. Bug report and
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
8 " feature request is welcome.
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
9
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
10 " Last Update: {{{
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
11 " 25th Sep 2002, by LH :
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
12 " (*) better support for the option
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
13 " (*) use some regex instead of several '||'.
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
14 " Oct 9th, 2003, by JT:
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
15 " (*) don't change indentation of lines starting with '%'
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
16 " 2005/06/15, Moshe Kaminsky <kaminsky AT math.huji.ac.il>
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
17 " (*) New variables:
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
18 " g:tex_items, g:tex_itemize_env, g:tex_noindent_env
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
19 " 2011/3/6, by Zhou YiChao <broken.zhou AT gmail.com>
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
20 " (*) Don't change indentation of lines starting with '%'
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
21 " I don't see any code with '%' and it doesn't work properly
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
22 " so I add some code.
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
23 " (*) New features: Add smartindent-like indent for "{}" and "[]".
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
24 " (*) New variables: g:tex_indent_brace
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
25 " 2011/9/25, by Zhou Yichao <broken.zhou AT gmail.com>
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
26 " (*) Bug fix: smartindent-like indent for "[]"
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
27 " (*) New features: Align with "&".
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
28 " (*) New variable: g:tex_indent_and.
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
29 " 2011/10/23 by Zhou Yichao <broken.zhou AT gmail.com>
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
30 " (*) Bug fix: improve the smartindent-like indent for "{}" and
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
31 " "[]".
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
32 " 2012/02/27 by Zhou Yichao <broken.zhou AT gmail.com>
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
33 " (*) Bug fix: support default folding marker.
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
34 " (*) Indent with "&" is not very handy. Make it not enable by
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
35 " default.
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
36 " 2012/03/06 by Zhou Yichao <broken.zhou AT gmail.com>
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
37 " (*) Modify "&" behavior and make it default again. Now "&"
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
38 " won't align when there are more then one "&" in the previous
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
39 " line.
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
40 " (*) Add indent "\left(" and "\right)"
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
41 " (*) Trust user when in "verbatim" and "lstlisting"
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
42 " 2012/03/11 by Zhou Yichao <broken.zhou AT gmail.com>
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
43 " (*) Modify "&" so that only indent when current line start with
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
44 " "&".
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
45 " 2012/03/12 by Zhou Yichao <broken.zhou AT gmail.com>
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
46 " (*) Modify indentkeys.
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
47 " 2012/03/18 by Zhou Yichao <broken.zhou AT gmail.com>
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
48 " (*) Add &cpo
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
49 " }}}
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
50
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
51 " Document: {{{
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
52 "
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
53 " To set the following options (ok, currently it's just one), add a line like
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
54 " let g:tex_indent_items = 1
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
55 " to your ~/.vimrc.
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
56 "
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
57 " * g:tex_indent_brace
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
58 "
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
59 " If this variable is unset or non-zero, it will use smartindent-like style
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
60 " for "{}" and "[]"
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
61 "
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
62 " * g:tex_indent_items
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
63 "
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
64 " If this variable is set, item-environments are indented like Emacs does
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
65 " it, i.e., continuation lines are indented with a shiftwidth.
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
66 "
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
67 " NOTE: I've already set the variable below; delete the corresponding line
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
68 " if you don't like this behaviour.
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
69 "
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
70 " Per default, it is unset.
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
71 "
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
72 " set unset
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
73 " ----------------------------------------------------------------
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
74 " \begin{itemize} \begin{itemize}
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
75 " \item blablabla \item blablabla
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
76 " bla bla bla bla bla bla
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
77 " \item blablabla \item blablabla
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
78 " bla bla bla bla bla bla
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
79 " \end{itemize} \end{itemize}
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
80 "
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
81 "
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
82 " * g:tex_items
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
83 "
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
84 " A list of tokens to be considered as commands for the beginning of an item
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
85 " command. The tokens should be separated with '\|'. The initial '\' should
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
86 " be escaped. The default is '\\bibitem\|\\item'.
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
87 "
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
88 " * g:tex_itemize_env
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
89 "
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
90 " A list of environment names, separated with '\|', where the items (item
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
91 " commands matching g:tex_items) may appear. The default is
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
92 " 'itemize\|description\|enumerate\|thebibliography'.
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
93 "
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
94 " * g:tex_noindent_env
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
95 "
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
96 " A list of environment names. separated with '\|', where no indentation is
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
97 " required. The default is 'document\|verbatim'.
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
98 "
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
99 " * g:tex_indent_and
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
100 "
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
101 " If this variable is unset or zero, vim will try to align the line with first
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
102 " "&". This is pretty useful when you use environment like table or align.
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
103 " Note that this feature need to search back some line, so vim may become
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
104 " a little slow.
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
105 "
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
106 " }}}
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
107
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
108 " Only define the function once
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
109 if exists("*GetTeXIndent")
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
110 finish
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
111 endif
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
112
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
113 if exists("b:did_indent")
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
114 finish
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
115 endif
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
116
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
117 let s:cpo_save = &cpo
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
118 set cpo&vim
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
119
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
120 " Define global variable {{{
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
121
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
122 let b:did_indent = 1
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
123
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
124 if !exists("g:tex_indent_items")
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
125 let g:tex_indent_items = 1
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
126 endif
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
127 if !exists("g:tex_indent_brace")
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
128 let g:tex_indent_brace = 1
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
129 endif
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
130 if !exists("g:tex_indent_and")
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
131 let g:tex_indent_and = 1
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
132 endif
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
133 if g:tex_indent_items
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
134 if !exists("g:tex_itemize_env")
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
135 let g:tex_itemize_env = 'itemize\|description\|enumerate\|thebibliography'
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
136 endif
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
137 if !exists('g:tex_items')
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
138 let g:tex_items = '\\bibitem\|\\item'
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
139 endif
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
140 else
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
141 let g:tex_items = ''
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
142 endif
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
143
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
144 if !exists("g:tex_indent_paretheses")
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
145 let g:tex_indent_paretheses = 1
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
146 endif
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
147
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
148 if !exists("g:tex_noindent_env")
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
149 let g:tex_noindent_env = 'document\|verbatim\|lstlisting'
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
150 endif "}}}
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
151
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
152 " VIM Setting " {{{
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
153 setlocal autoindent
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
154 setlocal nosmartindent
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
155 setlocal indentexpr=GetTeXIndent()
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
156 setlocal indentkeys&
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
157 exec 'setlocal indentkeys+=[,(,{,),},],\&' . substitute(g:tex_items, '^\|\(\\|\)', ',=', 'g')
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
158 let g:tex_items = '^\s*' . substitute(g:tex_items, '^\(\^\\s\*\)*', '', '')
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
159 " }}}
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
160
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
161 function GetTeXIndent() " {{{
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
162 " Find a non-blank line above the current line.
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
163 let lnum = prevnonblank(v:lnum - 1)
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
164
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
165 " Comment line is not what we need.
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
166 while lnum != 0 && getline(lnum) =~ '^\s*%'
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
167 let lnum = prevnonblank(lnum - 1)
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
168 endwhile
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
169
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
170 " At the start of the file use zero indent.
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
171 if lnum == 0
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
172 return 0
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
173 endif
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
174
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
175 let line = substitute(getline(lnum), '%.*', ' ','g') " last line
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
176 let cline = substitute(getline(v:lnum), '%.*', ' ', 'g') " current line
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
177
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
178 " We are in verbatim, so do what our user what.
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
179 if synIDattr(synID(v:lnum, indent(v:lnum), 1), "name") == "texZone"
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
180 if empty(cline)
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
181 return indent(lnum)
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
182 else
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
183 return indent(v:lnum)
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
184 end
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
185 endif
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
186
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
187 " You want to align with "&"
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
188 if g:tex_indent_and
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
189 " Align only when current line start with "&"
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
190 if line =~ '&.*\\\\' && cline =~ '^\s*&'
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
191 return indent(v:lnum) + stridx(line, "&") - stridx(cline, "&")
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
192 endif
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
193
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
194 " set line & lnum to the line which doesn't contain "&"
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
195 while lnum != 0 && (stridx(line, "&") != -1 || line =~ '^\s*%')
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
196 let lnum = prevnonblank(lnum - 1)
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
197 let line = getline(lnum)
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
198 endwhile
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
199 endif
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
200
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
201
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
202 if lnum == 0
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
203 return 0
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
204 endif
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
205
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
206 let ind = indent(lnum)
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
207
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
208 " New code for comment: retain the indent of current line
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
209 if cline =~ '^\s*%'
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
210 return indent(v:lnum)
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
211 endif
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
212
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
213 " Add a 'shiftwidth' after beginning of environments.
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
214 " Don't add it for \begin{document} and \begin{verbatim}
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
215 ""if line =~ '^\s*\\begin{\(.*\)}' && line !~ 'verbatim'
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
216 " LH modification : \begin does not always start a line
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
217 " ZYC modification : \end after \begin won't cause wrong indent anymore
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
218 if line =~ '\\begin{.*}' && line !~ g:tex_noindent_env
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
219 let ind = ind + &sw
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
220
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
221 if g:tex_indent_items
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
222 " Add another sw for item-environments
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
223 if line =~ g:tex_itemize_env
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
224 let ind = ind + &sw
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
225 endif
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
226 endif
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
227 endif
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
228
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
229 " Subtract a 'shiftwidth' when an environment ends
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
230 if cline =~ '\\end{.*}' && cline !~ g:tex_noindent_env
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
231
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
232 if g:tex_indent_items
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
233 " Remove another sw for item-environments
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
234 if cline =~ g:tex_itemize_env
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
235 let ind = ind - &sw
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
236 endif
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
237 endif
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
238
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
239 let ind = ind - &sw
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
240 endif
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
241
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
242 if g:tex_indent_brace
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
243 let sum1 = 0
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
244 for i in range(0, strlen(line)-1)
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
245 if line[i] == "}" || line[i] == "]" ||
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
246 \ strpart(line, i, 7) == '\right)'
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
247 let sum1 = max([0, sum1-1])
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
248 endif
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
249 if line[i] == "{" || line[i] == "[" ||
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
250 \ strpart(line, i, 6) == '\left('
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
251 let sum1 += 1
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
252 endif
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
253 endfor
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
254
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
255 let sum2 = 0
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
256 for i in reverse(range(0, strlen(cline)-1))
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
257 if cline[i] == "{" || cline[i] == "[" ||
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
258 \ strpart(cline, i, 6) == '\left('
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
259 let sum2 = max([0, sum2-1])
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
260 endif
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
261 if cline[i] == "}" || cline[i] == "]" ||
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
262 \ strpart(cline, i, 7) == '\right)'
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
263 let sum2 += 1
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
264 endif
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
265 endfor
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
266
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
267 let ind += (sum1 - sum2) * &sw
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
268 endif
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
269
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
270 if g:tex_indent_paretheses
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
271 endif
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
272
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
273 " Special treatment for 'item'
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
274 " ----------------------------
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
275
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
276 if g:tex_indent_items
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
277
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
278 " '\item' or '\bibitem' itself:
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
279 if cline =~ g:tex_items
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
280 let ind = ind - &sw
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
281 endif
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
282
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
283 " lines following to '\item' are intented once again:
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
284 if line =~ g:tex_items
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
285 let ind = ind + &sw
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
286 endif
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
287
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
288 endif
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
289
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
290 return ind
3445
2cfb68fa26cd Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3237
diff changeset
291 endfunction "}}}
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
292
3237
91e53bcb7946 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3224
diff changeset
293 let &cpo = s:cpo_save
91e53bcb7946 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3224
diff changeset
294 unlet s:cpo_save
91e53bcb7946 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3224
diff changeset
295
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
296 " vim: set sw=4 textwidth=80: