annotate runtime/indent/rst.vim @ 375:f14cbd913415 v7.0097

updated for version 7.0097
author vimboss
date Wed, 29 Jun 2005 22:40:58 +0000
parents 3fc0f57ecb91
children 1f3b1021f002
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
375
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
2 " Language: reStructuredText Documentation Format
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
3 " Maintainer: Nikolai Weibull <nikolai+work.vim@bitwi.se>
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
4 " Latest Revision: 2005-06-29
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
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 if exists("*GetRSTIndent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 function GetRSTIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 let lnum = prevnonblank(v:lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 if lnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 let ind = indent(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 let line = getline(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 if line =~ '^\s*[-*+]\s'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 let ind = ind + 2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 elseif line =~ '^\s*\d\+.\s'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 let ind = ind + matchend(substitute(line, '^\s*', '', ''), '\d\+.\s\+')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 let line = getline(v:lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 if line =~ '^\s*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 execute lnum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 call search('^\s*\%([-*+]\s\|\d\+.\s\|\.\.\|$\)', 'bW')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 let line = getline('.')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 if line =~ '^\s*[-*+]'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 let ind = ind - 2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 elseif line =~ '^\s*\d\+\.\s'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 let ind = ind - matchend(substitute(line, '^\s*', '', ''),
375
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
43 \ '\d\+\.\s\+')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 elseif line =~ '^\s*\.\.'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 let ind = ind - 3
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 let ind = ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 endfunction