comparison runtime/indent/rst.vim @ 3082:3502a7f991fc

Updated runtime files.
author Bram Moolenaar <bram@vim.org>
date Wed, 14 Sep 2011 17:55:08 +0200
parents 35a1d7bd6191
children 1218c5353e2b
comparison
equal deleted inserted replaced
3081:1e50bdaa24f8 3082:3502a7f991fc
1 " Vim indent file 1 " Vim indent file
2 " Language: reStructuredText Documentation Format 2 " Language: reStructuredText Documentation Format
3 " Maintainer: Nikolai Weibull <now@bitwi.se> 3 " Maintainer: Nikolai Weibull <now@bitwi.se>
4 " Latest Revision: 2006-12-20 4 " Latest Revision: 2011-08-03
5 5
6 if exists("b:did_indent") 6 if exists("b:did_indent")
7 finish 7 finish
8 endif 8 endif
9 let b:did_indent = 1 9 let b:did_indent = 1
14 14
15 if exists("*GetRSTIndent") 15 if exists("*GetRSTIndent")
16 finish 16 finish
17 endif 17 endif
18 18
19 let s:itemization_pattern = '^\s*[-*+]\s'
20 let s:enumeration_pattern = '^\s*\%(\d\+\|#\)\.\s\+'
21
19 function GetRSTIndent() 22 function GetRSTIndent()
20 let lnum = prevnonblank(v:lnum - 1) 23 let lnum = prevnonblank(v:lnum - 1)
21 if lnum == 0 24 if lnum == 0
22 return 0 25 return 0
23 endif 26 endif
24 27
25 let ind = indent(lnum) 28 let ind = indent(lnum)
26 let line = getline(lnum) 29 let line = getline(lnum)
27 30
28 if line =~ '^\s*[-*+]\s' 31 if line =~ s:itemization_pattern
29 let ind = ind + 2 32 let ind += 2
30 elseif line =~ '^\s*\d\+.\s' 33 elseif line =~ s:enumeration_pattern
31 let ind = ind + matchend(substitute(line, '^\s*', '', ''), '\d\+.\s\+') 34 let ind += matchend(line, s:enumeration_pattern)
32 endif 35 endif
33 36
34 let line = getline(v:lnum - 1) 37 let line = getline(v:lnum - 1)
35 38
39 " Indent :FIELD: lines. Don’t match if there is no text after the field or
40 " if the text ends with a sent-ender.
41 if line =~ '^:.\+:\s\{-1,\}\S.\+[^.!?:]$'
42 return matchend(line, '^:.\{-1,}:\s\+')
43 endif
44
36 if line =~ '^\s*$' 45 if line =~ '^\s*$'
37 execute lnum 46 execute lnum
38 call search('^\s*\%([-*+]\s\|\d\+.\s\|\.\.\|$\)', 'bW') 47 call search('^\s*\%([-*+]\s\|\%(\d\+\|#\)\.\s\|\.\.\|$\)', 'bW')
39 let line = getline('.') 48 let line = getline('.')
40 if line =~ '^\s*[-*+]' 49 if line =~ s:itemization_pattern
41 let ind = ind - 2 50 let ind -= 2
42 elseif line =~ '^\s*\d\+\.\s' 51 elseif line =~ s:enumeration_pattern
43 let ind = ind - matchend(substitute(line, '^\s*', '', ''), 52 let ind -= matchend(line, s:enumeration_pattern)
44 \ '\d\+\.\s\+')
45 elseif line =~ '^\s*\.\.' 53 elseif line =~ '^\s*\.\.'
46 let ind = ind - 3 54 let ind -= 3
47 else
48 let ind = ind
49 endif 55 endif
50 endif 56 endif
51 57
52 return ind 58 return ind
53 endfunction 59 endfunction