comparison runtime/indent/tex.vim @ 20552:74e3316c1d5a

Update runtime files Commit: https://github.com/vim/vim/commit/388a5d4f20b4b64341d1604aa238cab85827b892 Author: Bram Moolenaar <Bram@vim.org> Date: Tue May 26 21:20:45 2020 +0200 Update runtime files
author Bram Moolenaar <Bram@vim.org>
date Tue, 26 May 2020 21:30:04 +0200
parents cd513458728c
children 11b656e74444
comparison
equal deleted inserted replaced
20551:f1b23a9643fe 20552:74e3316c1d5a
62 " (*) Fix a bug between g:tex_noindent_env and g:tex_indent_items 62 " (*) Fix a bug between g:tex_noindent_env and g:tex_indent_items
63 " Now g:tex_noindent_env='document\|verbatim\|itemize' (Emacs 63 " Now g:tex_noindent_env='document\|verbatim\|itemize' (Emacs
64 " style) is supported. Thanks Miles Wheeler for reporting. 64 " style) is supported. Thanks Miles Wheeler for reporting.
65 " 2018/02/07 by Yichao Zhou <broken.zhou AT gmail.com> 65 " 2018/02/07 by Yichao Zhou <broken.zhou AT gmail.com>
66 " (*) Make indentation more smart in the normal mode 66 " (*) Make indentation more smart in the normal mode
67 " 2020/04/26 by Yichao Zhou <broken.zhou AT gmail.com>
68 " (*) Fix a bug related to \[ & \]. Thanks Manuel Boni for
69 " reporting.
67 " 70 "
68 " }}} 71 " }}}
69 72
70 " Document: {{{ 73 " Document: {{{
71 " 74 "
72 " To set the following options (ok, currently it's just one), add a line like 75 " For proper latex experience, please put
73 " let g:tex_indent_items = 1 76 " let g:tex_flavor = "latex"
74 " to your ~/.vimrc. 77 " into your vimrc.
75 " 78 "
76 " * g:tex_indent_brace 79 " * g:tex_indent_brace
77 " 80 "
78 " If this variable is unset or non-zero, it will use smartindent-like style 81 " If this variable is unset or non-zero, it will use smartindent-like style
79 " for "{}" and "[]". Now this only works if the open brace is the last 82 " for "{}" and "[]". Now this only works if the open brace is the last
182 endif 185 endif
183 186
184 let line = substitute(getline(lnum), '\s*%.*', '','g') " last line 187 let line = substitute(getline(lnum), '\s*%.*', '','g') " last line
185 let cline = substitute(getline(v:lnum), '\s*%.*', '', 'g') " current line 188 let cline = substitute(getline(v:lnum), '\s*%.*', '', 'g') " current line
186 189
190 let ccol = 1
191 while cline[ccol] =~ '\s'
192 let ccol += 1
193 endwhile
194
187 " We are in verbatim, so do what our user what. 195 " We are in verbatim, so do what our user what.
188 if synIDattr(synID(v:lnum, indent(v:lnum), 1), "name") == "texZone" 196 if synIDattr(synID(v:lnum, ccol, 1), "name") == "texZone"
189 if empty(cline) 197 if empty(cline)
190 return indent(lnum) 198 return indent(lnum)
191 else 199 else
192 return indent(v:lnum) 200 return indent(v:lnum)
193 end 201 endif
194 endif 202 endif
195 203
196 if lnum == 0 204 if lnum == 0
197 return 0 205 return 0
198 endif 206 endif
251 if line =~ '[[{]$' 259 if line =~ '[[{]$'
252 let ind += shiftwidth() 260 let ind += shiftwidth()
253 let stay = 0 261 let stay = 0
254 endif 262 endif
255 263
256 if cline =~ '^\s*\\\?[\]}]' && s:CheckPairedIsLastCharacter(v:lnum, indent(v:lnum)) 264 if cline =~ '^\s*\\\?[\]}]' && s:CheckPairedIsLastCharacter(v:lnum, ccol)
257 let ind -= shiftwidth() 265 let ind -= shiftwidth()
258 let stay = 0 266 let stay = 0
259 endif 267 endif
260 268
261 if line !~ '^\s*\\\?[\]}]' 269 if line !~ '^\s*\\\?[\]}]'
262 for i in range(indent(lnum)+1, strlen(line)-1) 270 for i in range(1, strlen(line)-1)
263 let char = line[i] 271 let char = line[i]
264 if char == ']' || char == '}' 272 if char == ']' || char == '}'
265 if s:CheckPairedIsLastCharacter(lnum, i) 273 if s:CheckPairedIsLastCharacter(lnum, i)
266 let ind -= shiftwidth() 274 let ind -= shiftwidth()
267 let stay = 0 275 let stay = 0