annotate runtime/indent/idlang.vim @ 2953:9f71f5a526af v7.3.249

updated for version 7.3.249 Problem: Wrong indenting for array initializer. Solution: Detect '}' in a better way. (Lech Lorens)
author Bram Moolenaar <bram@vim.org>
date Fri, 15 Jul 2011 14:12:30 +0200
parents 3fc0f57ecb91
children dd6c2497c997
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " IDL (Interactive Data Language) indent file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 " Language: IDL (ft=idlang)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 " Last change: 2002 Sep 23
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 " Maintainer: Aleksandar Jelenak <ajelenak AT yahoo.com>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 " Only load this indent file when no other was loaded.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 if exists("b:did_indent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 let b:did_indent = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 setlocal indentkeys=o,O,0=endif,0=ENDIF,0=endelse,0=ENDELSE,0=endwhile,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 \0=ENDWHILE,0=endfor,0=ENDFOR,0=endrep,0=ENDREP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 setlocal indentexpr=GetIdlangIndent(v:lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 " Only define the function once.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 if exists("*GetIdlangIndent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 function GetIdlangIndent(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 " First non-empty line above the current line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 let pnum = prevnonblank(v:lnum-1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 " v:lnum is the first non-empty line -- zero indent.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 if pnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 " Second non-empty line above the current line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 let pnum2 = prevnonblank(pnum-1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 " Current indent.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 let curind = indent(pnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 " Indenting of continued lines.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 if getline(pnum) =~ '\$\s*\(;.*\)\=$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 if getline(pnum2) !~ '\$\s*\(;.*\)\=$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 let curind = curind+&sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 if getline(pnum2) =~ '\$\s*\(;.*\)\=$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 let curind = curind-&sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 " Indenting blocks of statements.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 if getline(v:lnum) =~? '^\s*\(endif\|endelse\|endwhile\|endfor\|endrep\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 if getline(pnum) =~? 'begin\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 elseif indent(v:lnum) > curind-&sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 let curind = curind-&sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 return -1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 elseif getline(pnum) =~? 'begin\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 if indent(v:lnum) < curind+&sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 let curind = curind+&sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 return -1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 return curind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63