diff options
author | jluehrs2 <jluehrs2@uiuc.edu> | 2008-04-21 01:59:48 -0500 |
---|---|---|
committer | jluehrs2 <jluehrs2@uiuc.edu> | 2008-04-21 01:59:48 -0500 |
commit | dcdb904d97d328b0d71f03e6e0cc645956cf57fa (patch) | |
tree | 7d6ace2cd04186aaaebf39bf7c95445ec85ca57c | |
parent | 7efda1826fc1d515c62a174131fd5d567330fe02 (diff) | |
download | vim-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-- | vimrc | 20 |
1 files changed, 17 insertions, 3 deletions
@@ -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() |