Mercurial > vim
annotate runtime/indent/tex.vim @ 10829:8233f8f3f7ae v8.0.0304
patch 8.0.0304: assign test fails in the GUI
commit https://github.com/vim/vim/commit/1fb0d49803b4f57025ed6a43b1f5b9eb91524645
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Feb 4 21:50:19 2017 +0100
patch 8.0.0304: assign test fails in the GUI
Problem: Assign test fails in the GUI.
Solution: Skip the test for setting t_k1.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 04 Feb 2017 22:00:04 +0100 |
parents | 1bf1b88968a2 |
children | d183d629509e |
rev | line source |
---|---|
3224 | 1 " Vim indent file |
2 " Language: LaTeX | |
4437 | 3 " Maintainer: YiChao Zhou <broken.zhou AT gmail.com> |
3224 | 4 " Created: Sat, 16 Feb 2002 16:50:19 +0100 |
8392
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
5 " Version: 0.9.2 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
6 " Please email me if you found something I can do. Comments, bug report and |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
7 " feature request are welcome. |
3445 | 8 |
9 " Last Update: {{{ | |
10 " 25th Sep 2002, by LH : | |
3224 | 11 " (*) better support for the option |
12 " (*) use some regex instead of several '||'. | |
13 " Oct 9th, 2003, by JT: | |
14 " (*) don't change indentation of lines starting with '%' | |
3445 | 15 " 2005/06/15, Moshe Kaminsky <kaminsky AT math.huji.ac.il> |
3224 | 16 " (*) New variables: |
17 " g:tex_items, g:tex_itemize_env, g:tex_noindent_env | |
3445 | 18 " 2011/3/6, by Zhou YiChao <broken.zhou AT gmail.com> |
3224 | 19 " (*) Don't change indentation of lines starting with '%' |
20 " I don't see any code with '%' and it doesn't work properly | |
21 " so I add some code. | |
22 " (*) New features: Add smartindent-like indent for "{}" and "[]". | |
23 " (*) New variables: g:tex_indent_brace | |
3445 | 24 " 2011/9/25, by Zhou Yichao <broken.zhou AT gmail.com> |
3224 | 25 " (*) Bug fix: smartindent-like indent for "[]" |
26 " (*) New features: Align with "&". | |
3445 | 27 " (*) New variable: g:tex_indent_and. |
28 " 2011/10/23 by Zhou Yichao <broken.zhou AT gmail.com> | |
3224 | 29 " (*) Bug fix: improve the smartindent-like indent for "{}" and |
30 " "[]". | |
3445 | 31 " 2012/02/27 by Zhou Yichao <broken.zhou AT gmail.com> |
32 " (*) Bug fix: support default folding marker. | |
33 " (*) Indent with "&" is not very handy. Make it not enable by | |
34 " default. | |
35 " 2012/03/06 by Zhou Yichao <broken.zhou AT gmail.com> | |
36 " (*) Modify "&" behavior and make it default again. Now "&" | |
37 " won't align when there are more then one "&" in the previous | |
38 " line. | |
39 " (*) Add indent "\left(" and "\right)" | |
40 " (*) Trust user when in "verbatim" and "lstlisting" | |
41 " 2012/03/11 by Zhou Yichao <broken.zhou AT gmail.com> | |
42 " (*) Modify "&" so that only indent when current line start with | |
8392
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
43 " "&". |
3445 | 44 " 2012/03/12 by Zhou Yichao <broken.zhou AT gmail.com> |
45 " (*) Modify indentkeys. | |
46 " 2012/03/18 by Zhou Yichao <broken.zhou AT gmail.com> | |
47 " (*) Add &cpo | |
4437 | 48 " 2013/05/02 by Zhou Yichao <broken.zhou AT gmail.com> |
49 " (*) Fix problem about GetTeXIndent checker. Thank Albert Netymk | |
50 " for reporting this. | |
8392
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
51 " 2014/06/23 by Zhou Yichao <broken.zhou AT gmail.com> |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
52 " (*) Remove the feature g:tex_indent_and because it is buggy. |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
53 " (*) If there is not any obvious indentation hints, we do not |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
54 " alert our user's current indentation. |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
55 " (*) g:tex_indent_brace now only works if the open brace is the |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
56 " last character of that line. |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
57 " 2014/08/03 by Zhou Yichao <broken.zhou AT gmail.com> |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
58 " (*) Indent current line if last line has larger indentation |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
59 " 2014/08/09 by Zhou Yichao <broken.zhou AT gmail.com> |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
60 " (*) Add missing return value for s:GetEndIndentation(...) |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
61 " |
3445 | 62 " }}} |
3224 | 63 |
3445 | 64 " Document: {{{ |
3224 | 65 " |
66 " To set the following options (ok, currently it's just one), add a line like | |
67 " let g:tex_indent_items = 1 | |
68 " to your ~/.vimrc. | |
69 " | |
70 " * g:tex_indent_brace | |
71 " | |
72 " If this variable is unset or non-zero, it will use smartindent-like style | |
8392
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
73 " for "{}" and "[]". Now this only works if the open brace is the last |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
74 " character of that line. |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
75 " |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
76 " % Example 1 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
77 " \usetikzlibrary{ |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
78 " external |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
79 " } |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
80 " |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
81 " % Example 2 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
82 " \tikzexternalize[ |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
83 " prefix=tikz] |
3445 | 84 " |
3224 | 85 " * g:tex_indent_items |
86 " | |
87 " If this variable is set, item-environments are indented like Emacs does | |
88 " it, i.e., continuation lines are indented with a shiftwidth. | |
3445 | 89 " |
3224 | 90 " NOTE: I've already set the variable below; delete the corresponding line |
91 " if you don't like this behaviour. | |
92 " | |
93 " Per default, it is unset. | |
3445 | 94 " |
3224 | 95 " set unset |
96 " ---------------------------------------------------------------- | |
3445 | 97 " \begin{itemize} \begin{itemize} |
3224 | 98 " \item blablabla \item blablabla |
3445 | 99 " bla bla bla bla bla bla |
3224 | 100 " \item blablabla \item blablabla |
3445 | 101 " bla bla bla bla bla bla |
102 " \end{itemize} \end{itemize} | |
3224 | 103 " |
104 " | |
105 " * g:tex_items | |
106 " | |
3445 | 107 " A list of tokens to be considered as commands for the beginning of an item |
108 " command. The tokens should be separated with '\|'. The initial '\' should | |
3224 | 109 " be escaped. The default is '\\bibitem\|\\item'. |
110 " | |
111 " * g:tex_itemize_env | |
3445 | 112 " |
113 " A list of environment names, separated with '\|', where the items (item | |
114 " commands matching g:tex_items) may appear. The default is | |
3224 | 115 " 'itemize\|description\|enumerate\|thebibliography'. |
116 " | |
117 " * g:tex_noindent_env | |
118 " | |
3445 | 119 " A list of environment names. separated with '\|', where no indentation is |
3224 | 120 " required. The default is 'document\|verbatim'. |
3445 | 121 " }}} |
122 | |
123 " Only define the function once | |
3224 | 124 if exists("b:did_indent") |
125 finish | |
126 endif | |
3445 | 127 |
128 let s:cpo_save = &cpo | |
129 set cpo&vim | |
130 | |
131 " Define global variable {{{ | |
132 | |
3224 | 133 let b:did_indent = 1 |
134 | |
135 if !exists("g:tex_indent_items") | |
136 let g:tex_indent_items = 1 | |
137 endif | |
138 if !exists("g:tex_indent_brace") | |
139 let g:tex_indent_brace = 1 | |
140 endif | |
8392
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
141 if !exists("g:tex_max_scan_line") |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
142 let g:tex_max_scan_line = 60 |
3224 | 143 endif |
144 if g:tex_indent_items | |
145 if !exists("g:tex_itemize_env") | |
146 let g:tex_itemize_env = 'itemize\|description\|enumerate\|thebibliography' | |
147 endif | |
148 if !exists('g:tex_items') | |
3445 | 149 let g:tex_items = '\\bibitem\|\\item' |
3224 | 150 endif |
151 else | |
152 let g:tex_items = '' | |
153 endif | |
154 | |
155 if !exists("g:tex_noindent_env") | |
156 let g:tex_noindent_env = 'document\|verbatim\|lstlisting' | |
3445 | 157 endif "}}} |
3224 | 158 |
3445 | 159 " VIM Setting " {{{ |
3224 | 160 setlocal autoindent |
161 setlocal nosmartindent | |
162 setlocal indentexpr=GetTeXIndent() | |
3445 | 163 setlocal indentkeys& |
164 exec 'setlocal indentkeys+=[,(,{,),},],\&' . substitute(g:tex_items, '^\|\(\\|\)', ',=', 'g') | |
165 let g:tex_items = '^\s*' . substitute(g:tex_items, '^\(\^\\s\*\)*', '', '') | |
166 " }}} | |
3224 | 167 |
4437 | 168 function! GetTeXIndent() " {{{ |
3224 | 169 " Find a non-blank line above the current line. |
170 let lnum = prevnonblank(v:lnum - 1) | |
8392
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
171 let cnum = v:lnum |
3224 | 172 |
173 " Comment line is not what we need. | |
174 while lnum != 0 && getline(lnum) =~ '^\s*%' | |
175 let lnum = prevnonblank(lnum - 1) | |
176 endwhile | |
177 | |
178 " At the start of the file use zero indent. | |
179 if lnum == 0 | |
3445 | 180 return 0 |
3224 | 181 endif |
182 | |
8392
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
183 let line = substitute(getline(lnum), '\s*%.*', '','g') " last line |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
184 let cline = substitute(getline(v:lnum), '\s*%.*', '', 'g') " current line |
3224 | 185 |
3445 | 186 " We are in verbatim, so do what our user what. |
187 if synIDattr(synID(v:lnum, indent(v:lnum), 1), "name") == "texZone" | |
188 if empty(cline) | |
189 return indent(lnum) | |
190 else | |
191 return indent(v:lnum) | |
192 end | |
193 endif | |
194 | |
3224 | 195 if lnum == 0 |
3445 | 196 return 0 |
3224 | 197 endif |
198 | |
199 let ind = indent(lnum) | |
8392
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
200 let stay = 1 |
3224 | 201 |
202 " New code for comment: retain the indent of current line | |
203 if cline =~ '^\s*%' | |
204 return indent(v:lnum) | |
205 endif | |
206 | |
207 " Add a 'shiftwidth' after beginning of environments. | |
208 " Don't add it for \begin{document} and \begin{verbatim} | |
3445 | 209 ""if line =~ '^\s*\\begin{\(.*\)}' && line !~ 'verbatim' |
3224 | 210 " LH modification : \begin does not always start a line |
211 " ZYC modification : \end after \begin won't cause wrong indent anymore | |
212 if line =~ '\\begin{.*}' && line !~ g:tex_noindent_env | |
213 let ind = ind + &sw | |
8392
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
214 let stay = 0 |
3224 | 215 |
216 if g:tex_indent_items | |
217 " Add another sw for item-environments | |
218 if line =~ g:tex_itemize_env | |
219 let ind = ind + &sw | |
8392
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
220 let stay = 0 |
3224 | 221 endif |
222 endif | |
223 endif | |
224 | |
8392
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
225 if cline =~ '\\end{.*}' |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
226 let retn = s:GetEndIndentation(v:lnum) |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
227 if retn != -1 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
228 return retn |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
229 endif |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
230 end |
3224 | 231 " Subtract a 'shiftwidth' when an environment ends |
8392
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
232 if cline =~ '\\end{.*}' |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
233 \ && cline !~ g:tex_noindent_env |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
234 \ && cline !~ '\\begin{.*}.*\\end{.*}' |
3224 | 235 if g:tex_indent_items |
236 " Remove another sw for item-environments | |
237 if cline =~ g:tex_itemize_env | |
238 let ind = ind - &sw | |
8392
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
239 let stay = 0 |
3224 | 240 endif |
241 endif | |
242 | |
243 let ind = ind - &sw | |
8392
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
244 let stay = 0 |
3224 | 245 endif |
246 | |
247 if g:tex_indent_brace | |
8392
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
248 let char = line[strlen(line)-1] |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
249 if char == '[' || char == '{' |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
250 let ind += &sw |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
251 let stay = 0 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
252 endif |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
253 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
254 let cind = indent(v:lnum) |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
255 let char = cline[cind] |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
256 if (char == ']' || char == '}') && |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
257 \ s:CheckPairedIsLastCharacter(v:lnum, cind) |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
258 let ind -= &sw |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
259 let stay = 0 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
260 endif |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
261 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
262 for i in range(indent(lnum)+1, strlen(line)-1) |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
263 let char = line[i] |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
264 if char == ']' || char == '}' |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
265 if s:CheckPairedIsLastCharacter(lnum, i) |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
266 let ind -= &sw |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
267 let stay = 0 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
268 endif |
3224 | 269 endif |
270 endfor | |
3445 | 271 endif |
3224 | 272 |
273 " Special treatment for 'item' | |
274 " ---------------------------- | |
275 | |
276 if g:tex_indent_items | |
277 " '\item' or '\bibitem' itself: | |
278 if cline =~ g:tex_items | |
279 let ind = ind - &sw | |
8392
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
280 let stay = 0 |
3224 | 281 endif |
282 " lines following to '\item' are intented once again: | |
283 if line =~ g:tex_items | |
284 let ind = ind + &sw | |
8392
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
285 let stay = 0 |
3224 | 286 endif |
8392
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
287 endif |
3224 | 288 |
8392
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
289 if stay |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
290 " If there is no obvious indentation hint, we trust our user. |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
291 if empty(cline) |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
292 return ind |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
293 else |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
294 return max([indent(v:lnum), s:GetLastBeginIndentation(v:lnum)]) |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
295 endif |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
296 else |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
297 return ind |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
298 endif |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
299 endfunction "}}} |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
300 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
301 function! s:GetLastBeginIndentation(lnum) " {{{ |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
302 let matchend = 1 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
303 for lnum in range(a:lnum-1, max([a:lnum - g:tex_max_scan_line, 1]), -1) |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
304 let line = getline(lnum) |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
305 if line =~ '\\end{.*}' |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
306 let matchend += 1 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
307 endif |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
308 if line =~ '\\begin{.*}' |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
309 let matchend -= 1 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
310 endif |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
311 if matchend == 0 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
312 if line =~ g:tex_itemize_env |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
313 return indent(lnum) + 2 * &sw |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
314 endif |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
315 if line =~ g:tex_noindent_env |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
316 return indent(lnum) |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
317 endif |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
318 return indent(lnum) + &sw |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
319 endif |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
320 endfor |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
321 return -1 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
322 endfunction |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
323 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
324 function! s:GetEndIndentation(lnum) " {{{ |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
325 if getline(a:lnum) =~ '\\begin{.*}.*\\end{.*}' |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
326 return -1 |
3224 | 327 endif |
328 | |
8392
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
329 let min_indent = 100 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
330 let matchend = 1 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
331 for lnum in range(a:lnum-1, max([a:lnum-g:tex_max_scan_line, 1]), -1) |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
332 let line = getline(lnum) |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
333 if line =~ '\\end{.*}' |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
334 let matchend += 1 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
335 endif |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
336 if line =~ '\\begin{.*}' |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
337 let matchend -= 1 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
338 endif |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
339 if matchend == 0 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
340 return indent(lnum) |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
341 endif |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
342 if !empty(line) |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
343 let min_indent = min([min_indent, indent(lnum)]) |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
344 endif |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
345 endfor |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
346 return min_indent - &sw |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
347 endfunction |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
348 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
349 " Most of the code is from matchparen.vim |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
350 function! s:CheckPairedIsLastCharacter(lnum, col) "{{{ |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
351 " Get the character under the cursor and check if it's in 'matchpairs'. |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
352 let c_lnum = a:lnum |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
353 let c_col = a:col+1 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
354 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
355 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
356 let c = getline(c_lnum)[c_col-1] |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
357 let plist = split(&matchpairs, '.\zs[:,]') |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
358 let i = index(plist, c) |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
359 if i < 0 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
360 return 0 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
361 endif |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
362 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
363 " Figure out the arguments for searchpairpos(). |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
364 if i % 2 == 0 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
365 let s_flags = 'nW' |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
366 let c2 = plist[i + 1] |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
367 else |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
368 let s_flags = 'nbW' |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
369 let c2 = c |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
370 let c = plist[i - 1] |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
371 endif |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
372 if c == '[' |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
373 let c = '\[' |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
374 let c2 = '\]' |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
375 endif |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
376 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
377 " Find the match. When it was just before the cursor move it there for a |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
378 " moment. |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
379 let save_cursor = winsaveview() |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
380 call cursor(c_lnum, c_col) |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
381 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
382 " When not in a string or comment ignore matches inside them. |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
383 " We match "escape" for special items, such as lispEscapeSpecial. |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
384 let s_skip ='synIDattr(synID(line("."), col("."), 0), "name") ' . |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
385 \ '=~? "string\\|character\\|singlequote\\|escape\\|comment"' |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
386 execute 'if' s_skip '| let s_skip = 0 | endif' |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
387 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
388 let stopline = max([0, c_lnum - g:tex_max_scan_line]) |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
389 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
390 " Limit the search time to 300 msec to avoid a hang on very long lines. |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
391 " This fails when a timeout is not supported. |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
392 try |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
393 let [m_lnum, m_col] = searchpairpos(c, '', c2, s_flags, s_skip, stopline, 100) |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
394 catch /E118/ |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
395 endtry |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
396 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
397 call winrestview(save_cursor) |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
398 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
399 if m_lnum > 0 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
400 let line = getline(m_lnum) |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
401 return strlen(line) == m_col |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
402 endif |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
403 |
1bf1b88968a2
commit https://github.com/vim/vim/commit/328da0dcb7be34b594725eef6dc98d3ea6516d69
Christian Brabandt <cb@256bit.org>
parents:
4437
diff
changeset
|
404 return 0 |
3445 | 405 endfunction "}}} |
3224 | 406 |
3237 | 407 let &cpo = s:cpo_save |
408 unlet s:cpo_save | |
409 | |
3224 | 410 " vim: set sw=4 textwidth=80: |