annotate runtime/indent/yacc.vim @ 375:f14cbd913415 v7.0097

updated for version 7.0097
author vimboss
date Wed, 29 Jun 2005 22:40:58 +0000
parents 3fc0f57ecb91
children 1f3b1021f002
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 " Vim indent file
375
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
2 " Language: YACC input file
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
3 " Maintainer: Nikolai Weibull <nikolai+work.vim@bitwi.se>
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
4 " Latest Revision: 2005-06-29
7
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 let b:did_indent = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 setlocal indentexpr=GetYaccIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 setlocal indentkeys=!^F,o,O
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 " Only define the function once.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 if exists("*GetYaccIndent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 function GetYaccIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 if v:lnum == 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 let ind = indent(v:lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 let line = getline(v:lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 if line == ''
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 let ind = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 elseif line =~ '^\w\+\s*:'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 let ind = ind + matchend(line, '^\w\+\s*')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 elseif line =~ '^\s*;'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 let ind = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 let ind = indent(v:lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 endfunction