1
0
Fork 0
mirror of https://github.com/vim/vim synced 2025-03-16 06:47:52 +01:00
vim/runtime/indent/idlang.vim

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

66 lines
1.7 KiB
VimL
Raw Permalink Normal View History

2004-06-13 20:20:40 +00:00
" IDL (Interactive Data Language) indent file.
2021-10-04 21:32:54 +01:00
" Language: IDL (ft=idlang)
" Maintainer: Aleksandar Jelenak <ajelenak AT yahoo.com> (Invalid email address)
" Doug Kearns <dougkearns@gmail.com>
2022-04-08 17:45:08 +01:00
" Last change: 2022 Apr 06
2004-06-13 20:20:40 +00:00
" 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
2004-06-13 20:20:40 +00:00
setlocal indentexpr=GetIdlangIndent(v:lnum)
2022-04-08 17:45:08 +01:00
let b:undo_indent = "setl inde< indk<"
2004-06-13 20:20:40 +00:00
" 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+shiftwidth()
2004-06-13 20:20:40 +00:00
endif
else
if getline(pnum2) =~ '\$\s*\(;.*\)\=$'
let curind = curind-shiftwidth()
2004-06-13 20:20:40 +00:00
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-shiftwidth()
let curind = curind-shiftwidth()
2004-06-13 20:20:40 +00:00
else
return -1
endif
elseif getline(pnum) =~? 'begin\>'
if indent(v:lnum) < curind+shiftwidth()
let curind = curind+shiftwidth()
2004-06-13 20:20:40 +00:00
else
return -1
endif
endif
return curind
endfunction