6051
|
1 " Vim indent file
|
|
2 " Language: Rrst
|
|
3 " Author: Jakson Alves de Aquino <jalvesaq@gmail.com>
|
|
4 " Last Change: Wed Jul 09, 2014 07:33PM
|
|
5
|
|
6
|
|
7 " Only load this indent file when no other was loaded.
|
|
8 if exists("b:did_indent")
|
|
9 finish
|
|
10 endif
|
|
11 runtime indent/r.vim
|
|
12 let s:RIndent = function(substitute(&indentexpr, "()", "", ""))
|
|
13 let b:did_indent = 1
|
|
14
|
|
15 setlocal indentkeys=0{,0},:,!^F,o,O,e
|
|
16 setlocal indentexpr=GetRrstIndent()
|
|
17
|
|
18 if exists("*GetRrstIndent")
|
|
19 finish
|
|
20 endif
|
|
21
|
|
22 function GetRstIndent()
|
|
23 let pline = getline(v:lnum - 1)
|
|
24 let cline = getline(v:lnum)
|
|
25 if prevnonblank(v:lnum - 1) < v:lnum - 1 || cline =~ '^\s*[-\+\*]\s' || cline =~ '^\s*\d\+\.\s\+'
|
|
26 return indent(v:lnum)
|
|
27 elseif pline =~ '^\s*[-\+\*]\s'
|
|
28 return indent(v:lnum - 1) + 2
|
|
29 elseif pline =~ '^\s*\d\+\.\s\+'
|
|
30 return indent(v:lnum - 1) + 3
|
|
31 endif
|
|
32 return indent(prevnonblank(v:lnum - 1))
|
|
33 endfunction
|
|
34
|
|
35 function GetRrstIndent()
|
|
36 if getline(".") =~ '^\.\. {r .*}$' || getline(".") =~ '^\.\. \.\.$'
|
|
37 return 0
|
|
38 endif
|
|
39 if search('^\.\. {r', "bncW") > search('^\.\. \.\.$', "bncW")
|
|
40 return s:RIndent()
|
|
41 else
|
|
42 return GetRstIndent()
|
|
43 endif
|
|
44 endfunction
|
|
45
|
|
46 " vim: sw=2
|