bairui

JST Folds

Jan 19th, 2012
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let b:fold_levels = {}
  2. function! JST_Folds(lnum)
  3.   let line = getline(a:lnum)
  4.   if line =~ '^describe'
  5.     return '0'
  6.   elseif line =~ '^\s\+\(describe\|it\)'
  7.     let lead = matchstr(line, '^\s\+')
  8.     let b:fold_levels[lead] = lead
  9.     return 'a1'
  10.   elseif line =~ '^\s\+}\s*)\s*;'
  11.     let lead = matchstr(line, '^\s\+')
  12.     if has_key(b:fold_levels, lead)
  13.       call remove(b:fold_levels, lead)
  14.       return 's1'
  15.     else
  16.       return '='
  17.     endif
  18.   else
  19.     return '='
  20.   endif
  21. endfunction
  22.  
  23. set fdm=expr
  24. set fde=JST_Folds(v:lnum)
Advertisement
Add Comment
Please, Sign In to add comment