annotate runtime/indent/yacc.vim @ 4280:d8915d4b0c95

Added tag v7-3-889 for changeset cb0c694517a0
author Bram Moolenaar <bram@vim.org>
date Sun, 14 Apr 2013 16:19:03 +0200
parents 35a1d7bd6191
children 1218c5353e2b
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
1216
35a1d7bd6191 updated for version 7.1b
vimboss
parents: 856
diff changeset
2 " Language: YACC input file
839
1f3b1021f002 updated for version 7.0e05
vimboss
parents: 375
diff changeset
3 " Maintainer: Nikolai Weibull <now@bitwi.se>
1216
35a1d7bd6191 updated for version 7.1b
vimboss
parents: 856
diff changeset
4 " Latest Revision: 2006-12-20
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
1216
35a1d7bd6191 updated for version 7.1b
vimboss
parents: 856
diff changeset
15 setlocal nosmartindent
7
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("*GetYaccIndent")
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 GetYaccIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 if v:lnum == 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 let ind = indent(v:lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 let line = getline(v:lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 if line == ''
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 let ind = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 elseif line =~ '^\w\+\s*:'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 let ind = ind + matchend(line, '^\w\+\s*')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 elseif line =~ '^\s*;'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 let ind = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 let ind = indent(v:lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 endfunction