view runtime/indent/idlang.vim @ 35067:b2e515aab168 default tip

runtime(doc): CI: remove trailing white space in documentation Commit: https://github.com/vim/vim/commit/11250510404860a76d9e9cea4f99025277f607a5 Author: Christian Brabandt <cb@256bit.org> Date: Sat Apr 27 12:01:15 2024 +0200 runtime(doc): CI: remove trailing white space in documentation Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Sat, 27 Apr 2024 12:15:02 +0200
parents 6dd88e45d47d
children
line wrap: on
line source

" IDL (Interactive Data Language) indent file.
" Language:	IDL (ft=idlang)
" Maintainer:	Aleksandar Jelenak <ajelenak AT yahoo.com> (Invalid email address)
" 		Doug Kearns <dougkearns@gmail.com>
" Last change:	2022 Apr 06

" 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)

let b:undo_indent = "setl inde< indk<"

" 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()
      endif
   else
      if getline(pnum2) =~ '\$\s*\(;.*\)\=$'
	 let curind = curind-shiftwidth()
      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()
      else
	 return -1
      endif
   elseif getline(pnum) =~? 'begin\>'
      if indent(v:lnum) < curind+shiftwidth()
	 let curind = curind+shiftwidth()
      else
	 return -1
      endif
   endif
   return curind
endfunction