@@ -108,24 +108,25 @@ endfunction
108
108
function ! s: indentGuard (pos, prevline)
109
109
let l: l = a: prevline
110
110
let l: c = v: lnum - 1
111
+ let l: s = indent (l: c )
111
112
112
113
while l: c >= 1
113
- if l: l = ~ ' ^\S '
114
+ if l: s == 0 && strlen ( l: l ) > 0
114
115
" top-level start, stop looking
115
116
return g: haskell_indent_guard
116
117
elseif l: l = ~ ' ^\s\+[|,=]\s\+'
117
118
" guard block found
118
119
return match (l: l , ' [|,=]' )
119
120
else
120
- let l: m = match (l: l , ' \S' )
121
- if l: m >= 0 && l: m <= a: pos
121
+ if l: s > 0 && l: s <= a: pos
122
122
" found less deeper indentation (not starting with `,` or `=`)
123
123
" stop looking
124
- return l: m + g: haskell_indent_guard
124
+ return l: s + g: haskell_indent_guard
125
125
endif
126
126
endif
127
127
let l: c -= 1
128
128
let l: l = getline (l: c )
129
+ let l: s = indent (l: c )
129
130
endwhile
130
131
131
132
return -1
@@ -188,7 +189,7 @@ function! GetHaskellIndent()
188
189
189
190
" operator at end of previous line
190
191
if l: prevline = ~ ' [!#$%&*+./<>?@\\^|~-]\s*$'
191
- return match ( l: prevline , ' \S ' ) + &shiftwidth
192
+ return indent ( v: lnum - 1 ) + &shiftwidth
192
193
endif
193
194
194
195
" let foo =
@@ -242,7 +243,7 @@ function! GetHaskellIndent()
242
243
" >>foo
243
244
"
244
245
if l: prevline = ~ ' \C\<where\>\s*$'
245
- return match ( l: prevline , ' \S ' ) + get (g: , ' haskell_indent_after_bare_where' , &shiftwidth )
246
+ return indent ( v: lnum - 1 ) + get (g: , ' haskell_indent_after_bare_where' , &shiftwidth )
246
247
endif
247
248
248
249
" do
@@ -251,7 +252,7 @@ function! GetHaskellIndent()
251
252
" foo =
252
253
" >>bar
253
254
if l: prevline = ~ ' \C\(\<do\>\|=\)\s*$'
254
- return match ( l: prevline , ' \S ' ) + &shiftwidth
255
+ return indent ( v: lnum - 1 ) + &shiftwidth
255
256
endif
256
257
257
258
" do foo
@@ -267,7 +268,7 @@ function! GetHaskellIndent()
267
268
" >>bar -> quux
268
269
if l: prevline = ~ ' \C\<case\>.\+\<of\>\s*$'
269
270
if get (g: ,' haskell_indent_case_alternative' , 0 )
270
- return match ( l: prevline , ' \S ' ) + &shiftwidth
271
+ return indent ( v: lnum - 1 ) + &shiftwidth
271
272
else
272
273
return match (l: prevline , ' \C\<case\>' ) + g: haskell_indent_case
273
274
endif
@@ -300,7 +301,7 @@ function! GetHaskellIndent()
300
301
" newtype Foo = Foo
301
302
" >>deriving
302
303
if l: prevline = ~ ' \C^\s*\<\(newtype\|data\)\>[^{]\+' && l: line = ~ ' \C^\s*\<deriving\>'
303
- return match ( l: prevline , ' \S ' ) + &shiftwidth
304
+ return indent ( v: lnum - 1 ) + &shiftwidth
304
305
endif
305
306
306
307
" foo :: Int
@@ -405,7 +406,7 @@ function! GetHaskellIndent()
405
406
" foo
406
407
" >>{
407
408
if l: line = ~ ' ^\s*{'
408
- let l: s = match ( l: prevline , ' \S ' )
409
+ let l: s = indent ( v: lnum - 1 )
409
410
if l: s >= 0
410
411
return l: s + &shiftwidth
411
412
endif
@@ -423,7 +424,7 @@ function! GetHaskellIndent()
423
424
return match (l: prevline , ' in' ) - g: haskell_indent_in
424
425
endif
425
426
426
- return match ( l: prevline , ' \S ' ) + get (g: , ' haskell_indent_before_where' , &shiftwidth )
427
+ return indent ( v: lnum - 1 ) + get (g: , ' haskell_indent_before_where' , &shiftwidth )
427
428
endif
428
429
429
430
" let x = 1
@@ -488,7 +489,7 @@ function! GetHaskellIndent()
488
489
" foo
489
490
" >>:: Int
490
491
if l: line = ~ ' ^\s*::\s'
491
- return match ( l: prevline , ' \S ' ) + &shiftwidth
492
+ return indent ( v: lnum - 1 ) + &shiftwidth
492
493
endif
493
494
494
495
" indent closing brace, paren or bracket
0 commit comments