neovim/runtime/indent/idlang.vim
Justin M. Keyes a98a6996c2 re-integrate runtime/ vim-patch:0 #938
Vim runtime files based on 7.4.384 / hg changeset 7090d7f160f7

Excluding:
  Amiga icons (*.info, icons/)
  doc/hangulin.txt
  tutor/
  spell/
  lang/ (only used for menu translations)
  macros/maze/, macros/hanoi/, macros/life/, macros/urm/
      These were used to test vi compatibility.
  termcap
      "Demonstration of a termcap file (for the Amiga and Archimedes)"

Helped-by: Rich Wareham <rjw57@cam.ac.uk>
Helped-by: John <john.schmidt.h@gmail.com>
Helped-by: Yann <yann@yann-salaun.com>
Helped-by: Christophe Badoit <c.badoit@lesiteimmo.com>
Helped-by: drasill <github@tof2k.com>
Helped-by: Tae Sandoval Murgan <taecilla@gmail.com>
Helped-by: Lowe Thiderman <lowe.thiderman@gmail.com>
2014-07-29 02:12:31 +00:00

63 lines
1.5 KiB
VimL

" IDL (Interactive Data Language) indent file.
" Language: IDL (ft=idlang)
" Last change: 2012 May 18
" Maintainer: Aleksandar Jelenak <ajelenak AT yahoo.com>
" Only load this indent file when no other was loaded.
if exists("b:did_indent")
finish
endif
let b:did_indent = 1
setlocal indentkeys=o,O,0=endif,0=ENDIF,0=endelse,0=ENDELSE,0=endwhile,0=ENDWHILE,0=endfor,0=ENDFOR,0=endrep,0=ENDREP
setlocal indentexpr=GetIdlangIndent(v:lnum)
" Only define the function once.
if exists("*GetIdlangIndent")
finish
endif
function GetIdlangIndent(lnum)
" First non-empty line above the current line.
let pnum = prevnonblank(v:lnum-1)
" v:lnum is the first non-empty line -- zero indent.
if pnum == 0
return 0
endif
" Second non-empty line above the current line.
let pnum2 = prevnonblank(pnum-1)
" Current indent.
let curind = indent(pnum)
" Indenting of continued lines.
if getline(pnum) =~ '\$\s*\(;.*\)\=$'
if getline(pnum2) !~ '\$\s*\(;.*\)\=$'
let curind = curind+&sw
endif
else
if getline(pnum2) =~ '\$\s*\(;.*\)\=$'
let curind = curind-&sw
endif
endif
" Indenting blocks of statements.
if getline(v:lnum) =~? '^\s*\(endif\|endelse\|endwhile\|endfor\|endrep\)\>'
if getline(pnum) =~? 'begin\>'
elseif indent(v:lnum) > curind-&sw
let curind = curind-&sw
else
return -1
endif
elseif getline(pnum) =~? 'begin\>'
if indent(v:lnum) < curind+&sw
let curind = curind+&sw
else
return -1
endif
endif
return curind
endfunction