Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim indent file |
| 2 | " Language: Eterm configuration file |
| 3 | " Maintainer: Nikolai Weibull <source@pcppopper.org> |
| 4 | " URL: http://www.pcppopper.org/vim/indent/pcp/eterm/ |
| 5 | " Latest Revision: 2004-04-25 |
| 6 | " arch-tag: a22a92b1-c59f-4f47-8207-b21db6549b21 |
| 7 | |
| 8 | " Only load this indent file when no other was loaded. |
| 9 | if exists("b:did_indent") |
| 10 | finish |
| 11 | endif |
| 12 | |
| 13 | let b:did_indent = 1 |
| 14 | |
| 15 | setlocal indentexpr=GetEtermIndent() |
| 16 | setlocal indentkeys=!^F,o,O,=end |
| 17 | |
| 18 | " Only define the function once. |
| 19 | if exists("*GetEtermIndent") |
| 20 | finish |
| 21 | endif |
| 22 | |
| 23 | function GetEtermIndent() |
| 24 | " Find a non-blank line above the current line. |
| 25 | let lnum = prevnonblank(v:lnum - 1) |
| 26 | |
| 27 | " Hit the start of the file, use zero indent. |
| 28 | if lnum == 0 |
| 29 | return 0 |
| 30 | endif |
| 31 | |
| 32 | let line = getline(lnum) |
| 33 | let ind = indent(lnum) |
| 34 | |
| 35 | if line =~ '^\s*begin\>' |
| 36 | let ind = ind + &sw |
| 37 | endif |
| 38 | |
| 39 | let line = getline(v:lnum) |
| 40 | |
| 41 | " Check for closing brace on current line |
| 42 | if line =~ '^\s*end\>' |
| 43 | let ind = ind - &sw |
| 44 | endif |
| 45 | |
| 46 | return ind |
| 47 | endfunction |
| 48 | |
| 49 | " vim: set sts=2 sw=2: |