summaryrefslogtreecommitdiff
path: root/runtime/indent/eterm.vim
blob: 2e7ba185882041398492e8e669e9970e66cba0ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
" Vim indent file
" Language:	    Eterm configuration file
" Maintainer:	    Nikolai Weibull <source@pcppopper.org>
" URL:		    http://www.pcppopper.org/vim/indent/pcp/eterm/
" Latest Revision:  2004-04-25
" arch-tag:	    a22a92b1-c59f-4f47-8207-b21db6549b21

" Only load this indent file when no other was loaded.
if exists("b:did_indent")
  finish
endif

let b:did_indent = 1

setlocal indentexpr=GetEtermIndent()
setlocal indentkeys=!^F,o,O,=end

" Only define the function once.
if exists("*GetEtermIndent")
  finish
endif

function GetEtermIndent()
  " Find a non-blank line above the current line.
  let lnum = prevnonblank(v:lnum - 1)

  " Hit the start of the file, use zero indent.
  if lnum == 0
    return 0
  endif

  let line = getline(lnum)
  let ind = indent(lnum)

  if line =~ '^\s*begin\>'
    let ind = ind + &sw
  endif

  let line = getline(v:lnum)

  " Check for closing brace on current line
  if line =~ '^\s*end\>'
    let ind = ind - &sw
  endif

  return ind
endfunction

" vim: set sts=2 sw=2: