2004-06-13 20:20:40 +00:00
|
|
|
" Vim indent file
|
2007-05-10 18:32:52 +00:00
|
|
|
" Language: reStructuredText Documentation Format
|
2006-04-21 22:12:41 +00:00
|
|
|
" Maintainer: Nikolai Weibull <now@bitwi.se>
|
2007-05-10 18:32:52 +00:00
|
|
|
" Latest Revision: 2006-12-20
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
if exists("b:did_indent")
|
|
|
|
finish
|
|
|
|
endif
|
|
|
|
let b:did_indent = 1
|
|
|
|
|
|
|
|
setlocal indentexpr=GetRSTIndent()
|
2005-06-29 22:40:58 +00:00
|
|
|
setlocal indentkeys=!^F,o,O
|
2007-05-10 18:32:52 +00:00
|
|
|
setlocal nosmartindent
|
2004-06-13 20:20:40 +00:00
|
|
|
|
|
|
|
if exists("*GetRSTIndent")
|
|
|
|
finish
|
|
|
|
endif
|
|
|
|
|
|
|
|
function GetRSTIndent()
|
|
|
|
let lnum = prevnonblank(v:lnum - 1)
|
|
|
|
if lnum == 0
|
|
|
|
return 0
|
|
|
|
endif
|
|
|
|
|
|
|
|
let ind = indent(lnum)
|
|
|
|
let line = getline(lnum)
|
|
|
|
|
|
|
|
if line =~ '^\s*[-*+]\s'
|
|
|
|
let ind = ind + 2
|
|
|
|
elseif line =~ '^\s*\d\+.\s'
|
|
|
|
let ind = ind + matchend(substitute(line, '^\s*', '', ''), '\d\+.\s\+')
|
|
|
|
endif
|
|
|
|
|
|
|
|
let line = getline(v:lnum - 1)
|
|
|
|
|
|
|
|
if line =~ '^\s*$'
|
|
|
|
execute lnum
|
|
|
|
call search('^\s*\%([-*+]\s\|\d\+.\s\|\.\.\|$\)', 'bW')
|
|
|
|
let line = getline('.')
|
|
|
|
if line =~ '^\s*[-*+]'
|
|
|
|
let ind = ind - 2
|
|
|
|
elseif line =~ '^\s*\d\+\.\s'
|
|
|
|
let ind = ind - matchend(substitute(line, '^\s*', '', ''),
|
2007-05-10 18:32:52 +00:00
|
|
|
\ '\d\+\.\s\+')
|
2004-06-13 20:20:40 +00:00
|
|
|
elseif line =~ '^\s*\.\.'
|
|
|
|
let ind = ind - 3
|
|
|
|
else
|
|
|
|
let ind = ind
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
return ind
|
|
|
|
endfunction
|