summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjluehrs2 <jluehrs2@uiuc.edu>2008-04-21 21:53:51 -0500
committerjluehrs2 <jluehrs2@uiuc.edu>2008-04-21 21:53:51 -0500
commitf20e602980b7e58b64cf4a14e32697fb177213aa (patch)
tree0b48372bdbc89324dbad04fa4c10ca69d65dabd8
parent410bf930213a4396d70cc78a786bdf95e16823ff (diff)
downloadvim-foldtext-f20e602980b7e58b64cf4a14e32697fb177213aa.tar.gz
vim-foldtext-f20e602980b7e58b64cf4a14e32697fb177213aa.zip
generalize the enumerate folding to other list environments
-rw-r--r--vimrc20
1 files changed, 14 insertions, 6 deletions
diff --git a/vimrc b/vimrc
index 2e414ee..b9556b2 100644
--- a/vimrc
+++ b/vimrc
@@ -271,36 +271,44 @@ function Latex_foldtext() " {{{
return Base_foldtext(type . label)
endif
" }}}
- " format enumeration items nicely {{{
+ " format list items nicely {{{
let matches = matchlist(line, '\\item\%(\[\(.*\)\]\)\?')
if !empty(matches)
let item_name = []
let item_index = 0
let nesting = 0
+ let type = ''
for linenum in range(v:foldstart - 1, 0, -1)
let line = getline(linenum)
if line =~ '\\item'
if nesting == 0
let item_index += 1
endif
- elseif line =~ '\\begin{enumeration}'
+ elseif line =~ '\\begin{document}'
+ break
+ elseif line =~ '\\begin'
if nesting > 0
let nesting -= 1
else
+ let new_type = matchstr(line, '\\begin{\zs[^}]*\ze}')
+ if type == ''
+ let type = new_type
+ elseif type != new_type
+ break
+ endif
let item_name += [item_index]
let item_index = -1
endif
- elseif line =~ '\\end{enumeration}'
+ elseif line =~ '\\end'
let nesting += 1
- elseif line =~ '\\begin{document}'
- break
endif
endfor
let item_name = reverse(item_name)
for i in range(len(item_name))
let item_name[i] = s:enumeration(i, item_name[i])
endfor
- let line = 'Item: ' . join(item_name, '.')
+ let type = toupper(strpart(type, 0, 1)) . strpart(type, 1)
+ let line = type . ': ' . join(item_name, '.')
if matches[1] != ''
let line .= ' [' . matches[1] . ']'
endif