annotate runtime/indent/eiffel.vim @ 9881:4b53f6be10c0 v7.4.2215

commit https://github.com/vim/vim/commit/386600f0cbcb8add099c723cf84634f46df2f788 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Aug 15 22:16:25 2016 +0200 patch 7.4.2215 Problem: It's not easy to find out if a window is a quickfix or location list window. Solution: Add "loclist" and "quickfix" entries to the dict returnec by getwininfo(). (Yegappan Lakshmanan)
author Christian Brabandt <cb@256bit.org>
date Mon, 15 Aug 2016 22:30:06 +0200
parents 9cb3a75a20b9
children d0a20101ecb2
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 " Language: Eiffel
3557
9cb3a75a20b9 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
3 " Maintainer: Jocelyn Fiat <jfiat@eiffel.com>
26
404aac550f35 updated for version 7.0017
vimboss
parents: 7
diff changeset
4 " Previous-Maintainer: David Clarke <gadicath@dishevelled.net>
3557
9cb3a75a20b9 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
5 " Contributions from: Thilo Six
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 36
diff changeset
6 " $Date: 2004/12/09 21:33:52 $
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 36
diff changeset
7 " $Revision: 1.3 $
3557
9cb3a75a20b9 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
8 " URL: https://github.com/eiffelhub/vim-eiffel
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 " Only load this indent file when no other was loaded.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 if exists("b:did_indent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 let b:did_indent = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 setlocal indentexpr=GetEiffelIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 setlocal nolisp
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 setlocal nosmartindent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 setlocal nocindent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 setlocal autoindent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 setlocal comments=:--
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 setlocal indentkeys+==end,=else,=ensure,=require,=check,=loop,=until
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 setlocal indentkeys+==creation,=feature,=inherit,=class,=is,=redefine,=rename,=variant
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 setlocal indentkeys+==invariant,=do,=local,=export
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25
3557
9cb3a75a20b9 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
26 let b:undo_indent = "setl smartindent< indentkeys< indentexpr< autoindent< comments< "
9cb3a75a20b9 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
27
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 " Define some stuff
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 " keywords grouped by indenting
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 let s:trust_user_indent = '\(+\)\(\s*\(--\).*\)\=$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 let s:relative_indent = '^\s*\(deferred\|class\|feature\|creation\|inherit\|loop\|from\|until\|if\|else\|elseif\|ensure\|require\|check\|do\|local\|invariant\|variant\|rename\|redefine\|do\|export\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 let s:outdent = '^\s*\(else\|invariant\|variant\|do\|require\|until\|loop\|local\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 let s:no_indent = '^\s*\(class\|feature\|creation\|inherit\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 let s:single_dent = '^[^-]\+[[:alnum:]]\+ is\(\s*\(--\).*\)\=$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 let s:inheritance_dent = '\s*\(redefine\|rename\|export\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 " Only define the function once.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 if exists("*GetEiffelIndent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 endif
3557
9cb3a75a20b9 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
42
3526
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
43 let s:keepcpo= &cpo
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
44 set cpo&vim
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 function GetEiffelIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 " Eiffel Class indenting
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 " Find a non-blank line above the current line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 let lnum = prevnonblank(v:lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 " At the start of the file use zero indent.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 if lnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 " trust the user's indenting
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 if getline(lnum) =~ s:trust_user_indent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 return -1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 " Add a 'shiftwidth' after lines that start with an indent word
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 let ind = indent(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 if getline(lnum) =~ s:relative_indent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 let ind = ind + &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 " Indent to single indent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 if getline(v:lnum) =~ s:single_dent && getline(v:lnum) !~ s:relative_indent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 \ && getline(v:lnum) !~ '\s*\<\(and\|or\|implies\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 let ind = &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 " Indent to double indent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 if getline(v:lnum) =~ s:inheritance_dent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 let ind = 2 * &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 " Indent line after the first line of the function definition
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 if getline(lnum) =~ s:single_dent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 let ind = ind + &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 " The following should always be at the start of a line, no indenting
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 if getline(v:lnum) =~ s:no_indent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 let ind = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 " Subtract a 'shiftwidth', if this isn't the first thing after the 'is'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 " or first thing after the 'do'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 if getline(v:lnum) =~ s:outdent && getline(v:lnum - 1) !~ s:single_dent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 \ && getline(v:lnum - 1) !~ '^\s*do\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 let ind = ind - &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 " Subtract a shiftwidth for end statements
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 if getline(v:lnum) =~ '^\s*end\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 let ind = ind - &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 " set indent of zero end statements that are at an indent of 3, this should
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 " only ever be the class's end.
26
404aac550f35 updated for version 7.0017
vimboss
parents: 7
diff changeset
104 if getline(v:lnum) =~ '^\s*end\>' && ind == &sw
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 let ind = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110
3526
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
111 let &cpo = s:keepcpo
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
112 unlet s:keepcpo
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
113
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 " vim:sw=2