home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / vim60.zip / vim60rt2.zip / vim / vim60 / indent / yacc.vim < prev   
Text File  |  2001-09-26  |  822b  |  43 lines

  1. " Maintainer    : Nikolai 'pcp' Weibull <da.box@home.se>
  2. " URL        : http://www.pcppopper.org/
  3. " Revised on    : Sun, 16 Sep 2001 19:41:11 +0200
  4.  
  5. " Only load this indent file when no other was loaded.
  6. if exists("b:did_indent")
  7.     finish
  8. endif
  9.  
  10. let b:did_indent = 1
  11.  
  12. setlocal indentexpr=GetYaccIndent()
  13. setlocal indentkeys=!^F,o,O
  14.  
  15. " Only define the function once.
  16. if exists("*GetYaccIndent")
  17.     finish
  18. endif
  19.  
  20. function GetYaccIndent()
  21.     if v:lnum == 1
  22.     return 0
  23.     endif
  24.  
  25.     let ind = indent(v:lnum - 1)
  26.     let line = getline(v:lnum - 1)
  27.  
  28.     if line == ''
  29.     let ind = 0
  30.     elseif line =~ '^\w\+\s*:'
  31.     let ind = ind + matchend(line, '^\w\+\s*')
  32.     elseif line =~ '^\s*;'
  33.     let ind = 0
  34.     else
  35.     let ind = indent(v:lnum)
  36.     endif
  37.  
  38.     return ind
  39. endfunction
  40.  
  41. " vim: set sw=4 sts=4:
  42.  
  43.