@@ -1,139 +0,0 @@
1−" indentation for idris (idris-lang.org)
2−"
3−" Based on haskell indentation by motemen <motemen@gmail.com>
4−"
5−" author: raichoo (raichoo@googlemail.com)
6−" date: Mar 19 2013
7−"
8−" Modify g:idris_indent_if and g:idris_indent_case to
9−" change indentation for `if'(default 3) and `case'(default 5).
10−" Example (in .vimrc):
11−" > let g:idris_indent_if = 2
12−
13−if exists('b:did_indent')
14− finish
15−endif
16−
17−let b:did_indent = 1
18−
19−if !exists('g:idris_indent_if')
20− " if bool
21− " >>>then ...
22− " >>>else ...
23− let g:idris_indent_if = 3
24−endif
25−
26−if !exists('g:idris_indent_case')
27− " case xs of
28− " >>>>>[] -> ...
29− " >>>>>(y::ys) -> ...
30− let g:idris_indent_case = 5
31−endif
32−
33−if !exists('g:idris_indent_let')
34− " let x : Nat = O in
35− " >>>>x
36− let g:idris_indent_let = 4
37−endif
38−
39−if !exists('g:idris_indent_rewrite')
40− " rewrite prf in expr
41− " >>>>x
42− let g:idris_indent_rewrite = 8
43−endif
44−
45−if !exists('g:idris_indent_where')
46− " where f : Nat -> Nat
47− " >>>>>>f x = x
48− let g:idris_indent_where = 6
49−endif
50−
51−if !exists('g:idris_indent_do')
52− " do x <- a
53− " >>>y <- b
54− let g:idris_indent_do = 3
55−endif
56−
57−setlocal indentexpr=GetIdrisIndent()
58−setlocal indentkeys=!^F,o,O,}
59−
60−function! GetIdrisIndent()
61− let prevline = getline(v:lnum - 1)
62−
63− if prevline =~ '[!#$%&*+./<>?@\\^|~-]\s*$'
64− let s = match(prevline, '[:=]')
65− if s > 0
66− return s + 2
67− else
68− return match(prevline, '\S')
69− endif
70− endif
71−
72− if prevline =~ '[{([][^})\]]\+$'
73− return match(prevline, '[{([]')
74− endif
75−
76− if prevline =~ '\<let\>\s\+.\+\<in\>\s*$'
77− return match(prevline, 'let') + g:idris_indent_let
78− endif
79−
80− if prevline =~ '\<rewrite\>\s\+.\+\<in\>\s*$'
81− return match(prevline, 'rewrite') + g:idris_indent_rewrite
82− endif
83−
84− if prevline !~ '\<else\>'
85− let s = match(prevline, '\<if\>.*\&.*\zs\<then\>')
86− if s > 0
87− return s
88− endif
89−
90− let s = match(prevline, '\<if\>')
91− if s > 0
92− return s + g:idris_indent_if
93− endif
94− endif
95−
96− if prevline =~ '\(\<where\>\|\<do\>\|=\|[{([]\)\s*$'
97− return match(prevline, '\S') + &shiftwidth
98− endif
99−
100− if prevline =~ '\<where\>\s\+\S\+.*$'
101− return match(prevline, '\<where\>') + g:idris_indent_where
102− endif
103−
104− if prevline =~ '\<do\>\s\+\S\+.*$'
105− return match(prevline, '\<do\>') + g:idris_indent_do
106− endif
107−
108− if prevline =~ '^\s*\<\(co\)\?data\>\s\+[^=]\+\s\+=\s\+\S\+.*$'
109− return match(prevline, '=')
110− endif
111−
112− if prevline =~ '\<with\>\s\+([^)]*)\s*$'
113− return match(prevline, '\S') + &shiftwidth
114− endif
115−
116− if prevline =~ '\<case\>\s\+.\+\<of\>\s*$'
117− return match(prevline, 'case') + g:idris_indent_case
118− endif
119−
120− if prevline =~ '^\s*\(\<namespace\>\|\<\(co\)\?data\>\)\s\+\S\+\s*$'
121− return match(prevline, '\(\<namespace\>\|\<\(co\)\?data\>\)') + &shiftwidth
122− endif
123−
124− if prevline =~ '^\s*\(\<using\>\|\<parameters\>\)\s*([^(]*)\s*$'
125− return match(prevline, '\(\<using\>\|\<parameters\>\)') + &shiftwidth
126− endif
127−
128− if prevline =~ '^\s*\<mutual\>\s*$'
129− return match(prevline, '\<mutual\>') + &shiftwidth
130− endif
131−
132− let line = getline(v:lnum)
133−
134− if (line =~ '^\s*}\s*' && prevline !~ '^\s*;')
135− return match(prevline, '\S') - &shiftwidth
136− endif
137−
138− return match(prevline, '\S')
139−endfunction