Stefan Liebl f388695793 move vimfiles.stefan/... to vimfiles.stefan/after
Change-Id: I0469122bf65ddf24129151b2a82619011a6a4879
2014-06-24 10:39:28 +02:00

63 lines
1.4 KiB
VimL

" Vim indent file
" Language: a2l
" Maintainer: Stefan Liebl
if exists("b:did_indent")
finish
endif
let b:did_indent = 1
setlocal indentexpr=GetA2LIndent()
setlocal nolisp
setlocal nosmartindent
setlocal autoindent
setlocal indentkeys+=},=/end
" Only define the function once
if exists("*GetA2LIndent")
finish
endif
function GetA2LIndent()
" Do not change indentation of commented lines.
if exists("b:commentstring")
if getline(v:lnum) =~ '^' . b:commentstring . '.*'
return 0
endif
endif
" Find a non-blank line above the current line, that's not a comment
let lnum = prevnonblank(v:lnum - 1)
if exists("b:commentstring")
while getline(lnum) =~ '^' . b:commentstring
let lnum = prevnonblank(lnum - 1)
if lnum == 0
break
endif
endwhile
endif
" At the start of the file use zero indent.
if lnum == 0 | return 0
endif
let ind = indent(lnum)
let line = getline(lnum) " last line
let cline = getline(v:lnum) " current line
" Add a 'shiftwidth' after beginning of environments.
" Don't add it for /begin ... /end
if line =~ '/begin' && line !~ '/end'
let ind = ind + &sw
endif
" Subtract a 'shiftwidth' when an environment ends
if cline =~ '^\s*/end'
let ind = ind - &sw
endif
return ind
endfunction