home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / unix / vim-6.2.tar.bz2 / vim-6.2.tar / vim62 / runtime / indent / idlang.vim < prev    next >
Encoding:
Text File  |  2002-09-23  |  1.5 KB  |  64 lines

  1. " IDL (Interactive Data Language) indent file.
  2. " Language: IDL (ft=idlang)
  3. " Last change:    2002 Sep 23
  4. " Maintainer: Aleksandar Jelenak <ajelenak AT yahoo.com>
  5.  
  6. " Only load this indent file when no other was loaded.
  7. if exists("b:did_indent")
  8.    finish
  9. endif
  10. let b:did_indent = 1
  11.  
  12. setlocal indentkeys=o,O,0=endif,0=ENDIF,0=endelse,0=ENDELSE,0=endwhile,
  13.             \0=ENDWHILE,0=endfor,0=ENDFOR,0=endrep,0=ENDREP
  14.  
  15. setlocal indentexpr=GetIdlangIndent(v:lnum)
  16.  
  17. " Only define the function once.
  18. if exists("*GetIdlangIndent")
  19.    finish
  20. endif
  21.  
  22. function GetIdlangIndent(lnum)
  23.    " First non-empty line above the current line.
  24.    let pnum = prevnonblank(v:lnum-1)
  25.    " v:lnum is the first non-empty line -- zero indent.
  26.    if pnum == 0
  27.       return 0
  28.    endif
  29.    " Second non-empty line above the current line.
  30.    let pnum2 = prevnonblank(pnum-1)
  31.  
  32.    " Current indent.
  33.    let curind = indent(pnum)
  34.  
  35.    " Indenting of continued lines.
  36.    if getline(pnum) =~ '\$\s*\(;.*\)\=$'
  37.       if getline(pnum2) !~ '\$\s*\(;.*\)\=$'
  38.      let curind = curind+&sw
  39.       endif
  40.    else
  41.       if getline(pnum2) =~ '\$\s*\(;.*\)\=$'
  42.      let curind = curind-&sw
  43.       endif
  44.    endif
  45.  
  46.    " Indenting blocks of statements.
  47.    if getline(v:lnum) =~? '^\s*\(endif\|endelse\|endwhile\|endfor\|endrep\)\>'
  48.       if getline(pnum) =~? 'begin\>'
  49.       elseif indent(v:lnum) > curind-&sw
  50.      let curind = curind-&sw
  51.       else
  52.      return -1
  53.       endif
  54.    elseif getline(pnum) =~? 'begin\>'
  55.       if indent(v:lnum) < curind+&sw
  56.      let curind = curind+&sw
  57.       else
  58.      return -1
  59.       endif
  60.    endif
  61.    return curind
  62. endfunction
  63.  
  64.