summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjluehrs2 <jluehrs2@uiuc.edu>2008-04-21 01:59:48 -0500
committerjluehrs2 <jluehrs2@uiuc.edu>2008-04-21 01:59:48 -0500
commitdcdb904d97d328b0d71f03e6e0cc645956cf57fa (patch)
tree7d6ace2cd04186aaaebf39bf7c95445ec85ca57c
parent7efda1826fc1d515c62a174131fd5d567330fe02 (diff)
downloadvim-foldtext-dcdb904d97d328b0d71f03e6e0cc645956cf57fa.tar.gz
vim-foldtext-dcdb904d97d328b0d71f03e6e0cc645956cf57fa.zip
look for the label for a theorem, etc on following lines if it's not on the same line
-rw-r--r--vimrc20
1 files changed, 17 insertions, 3 deletions
diff --git a/vimrc b/vimrc
index 47aa533..6cee219 100644
--- a/vimrc
+++ b/vimrc
@@ -183,10 +183,24 @@ function Latex_foldtext()
let line = getline(v:foldstart)
" if we get the start of a theorem, format the display nicely
- " XXX: allow the label to be on the following line
- let matches = matchlist(line, '\\begin{\([^}]*\)}.*\\label{\([^}]*\)}')
+ let matches = matchlist(line, '\\begin{\([^}]*\)}')
if !empty(matches) && has_key(s:latex_types, matches[1])
- return Base_foldtext(s:latex_types[matches[1]] . ": " . matches[2])
+ let type = s:latex_types[matches[1]]
+ let label = ''
+ let linenum = v:foldstart - 1
+ while linenum <= v:foldend
+ let linenum += 1
+ let line = getline(linenum)
+ let matches = matchlist(line, '\\label{\([^}]*\)}')
+ if !empty(matches)
+ let label = matches[1]
+ break
+ endif
+ endwhile
+ if label != ''
+ let label = ": " . label
+ endif
+ return Base_foldtext(type . label)
endif
return Base_foldtext()