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