annotate runtime/indent/rst.vim @ 1362:2f70b8f1f1e3 v7.1.076

updated for version 7.1-076
author vimboss
date Tue, 14 Aug 2007 20:54:49 +0000
parents 35a1d7bd6191
children 3502a7f991fc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Vim indent file
1216
35a1d7bd6191 updated for version 7.1b
vimboss
parents: 856
diff changeset
2 " Language: reStructuredText Documentation Format
839
1f3b1021f002 updated for version 7.0e05
vimboss
parents: 375
diff changeset
3 " Maintainer: Nikolai Weibull <now@bitwi.se>
1216
35a1d7bd6191 updated for version 7.1b
vimboss
parents: 856
diff changeset
4 " Latest Revision: 2006-12-20
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 if exists("b:did_indent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 let b:did_indent = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 setlocal indentexpr=GetRSTIndent()
375
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
12 setlocal indentkeys=!^F,o,O
1216
35a1d7bd6191 updated for version 7.1b
vimboss
parents: 856
diff changeset
13 setlocal nosmartindent
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 if exists("*GetRSTIndent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 function GetRSTIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 let lnum = prevnonblank(v:lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 if lnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 let ind = indent(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 let line = getline(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 if line =~ '^\s*[-*+]\s'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 let ind = ind + 2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 elseif line =~ '^\s*\d\+.\s'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 let ind = ind + matchend(substitute(line, '^\s*', '', ''), '\d\+.\s\+')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 let line = getline(v:lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 if line =~ '^\s*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 execute lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 call search('^\s*\%([-*+]\s\|\d\+.\s\|\.\.\|$\)', 'bW')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 let line = getline('.')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 if line =~ '^\s*[-*+]'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 let ind = ind - 2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 elseif line =~ '^\s*\d\+\.\s'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 let ind = ind - matchend(substitute(line, '^\s*', '', ''),
1216
35a1d7bd6191 updated for version 7.1b
vimboss
parents: 856
diff changeset
44 \ '\d\+\.\s\+')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 elseif line =~ '^\s*\.\.'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 let ind = ind - 3
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 let ind = ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 endfunction