annotate runtime/indent/hamster.vim @ 3693:c612d154bcdd v7.3.606

updated for version 7.3.606 Problem: CTRL-P completion has a problem with multi-byte characters. Solution: Check for next character being NUL properly. (Yasuhiro Matsumoto)
author Bram Moolenaar <bram@vim.org>
date Thu, 19 Jul 2012 17:18:26 +0200
parents 96cd8222a819
children 63b0b7b79b25
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1125
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
1 " Vim indent file
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
2 " Language: Hamster Script
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
3 " Version: 2.0.6.0
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
4 " Last Change: Wed Nov 08 2006 12:02:42 PM
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
5 " Maintainer: David Fishburn <fishburn@ianywhere.com>
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
6
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
7 " Only load this indent file when no other was loaded.
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
8 if exists("b:did_indent")
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
9 finish
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
10 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
11 let b:did_indent = 1
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
12
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
13 setlocal indentkeys+==~if,=~else,=~endif,=~endfor,=~endwhile
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
14 setlocal indentkeys+==~do,=~until,=~while,=~repeat,=~for,=~loop
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
15 setlocal indentkeys+==~sub,=~endsub
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
16
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
17 " Define the appropriate indent function but only once
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
18 setlocal indentexpr=HamGetFreeIndent()
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
19 if exists("*HamGetFreeIndent")
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
20 finish
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
21 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
22
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
23 function HamGetIndent(lnum)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
24 let ind = indent(a:lnum)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
25 let prevline=getline(a:lnum)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
26
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
27 " Add a shiftwidth to statements following if, else, elseif,
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
28 " case, select, default, do, until, while, for, start
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
29 if prevline =~? '^\s*\<\(if\|else\%(if\)\?\|for\|repeat\|do\|while\|sub\)\>'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
30 let ind = ind + &sw
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
31 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
32
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
33 " Subtract a shiftwidth from else, elseif, end(if|while|for), until
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
34 let line = getline(v:lnum)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
35 if line =~? '^\s*\(else\|elseif\|loop\|until\|end\%(if\|while\|for\|sub\)\)\>'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
36 let ind = ind - &sw
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
37 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
38
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
39 return ind
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
40 endfunction
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
41
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
42 function HamGetFreeIndent()
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
43 " Find the previous non-blank line
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
44 let lnum = prevnonblank(v:lnum - 1)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
45
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
46 " Use zero indent at the top of the file
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
47 if lnum == 0
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
48 return 0
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
49 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
50
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
51 let ind=HamGetIndent(lnum)
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
52 return ind
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
53 endfunction
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
54
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
55 " vim:sw=2 tw=80