annotate runtime/indent/hamster.vim @ 15060:a7b9fa73d238 v8.1.0541

patch 8.1.0541: help message in dosinst.c is outdated commit https://github.com/vim/vim/commit/2b84949ad8f247e5d142e2fb1371b3e37567977a Author: Bram Moolenaar <Bram@vim.org> Date: Wed Nov 21 13:58:35 2018 +0100 patch 8.1.0541: help message in dosinst.c is outdated Problem: Help message in dosinst.c is outdated. Solution: Update the comment. (Ken Takata, closes https://github.com/vim/vim/issues/3626)
author Bram Moolenaar <Bram@vim.org>
date Wed, 21 Nov 2018 14:00:09 +0100
parents 63b0b7b79b25
children 3b34837f4538
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\)\>'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 1125
diff changeset
30 let ind = ind + shiftwidth()
1125
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\)\)\>'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 1125
diff changeset
36 let ind = ind - shiftwidth()
1125
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