annotate runtime/indent/hamster.vim @ 7564:aee06f1762e0 v7.4.1082

commit https://github.com/vim/vim/commit/858b96f382eeb8f1eab5100639e7b09523a6a2a1 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jan 10 16:12:24 2016 +0100 patch 7.4.1082 Problem: The Tcl interface is always skipping memory free on exit. Solution: Only skip for dynamically loaded Tcl.
author Christian Brabandt <cb@256bit.org>
date Sun, 10 Jan 2016 16:15:06 +0100
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