Skip to content

Commit 24c2df3

Browse files
committed
fix multiline function decl indentation
1 parent 84dc711 commit 24c2df3

File tree

1 file changed

+35
-23
lines changed

1 file changed

+35
-23
lines changed

indent/haskell.vim

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,14 @@ function! GetHaskellIndent()
304304
endif
305305
endif
306306

307+
" foo :: Int
308+
" -> Int
309+
" >>>>-> Int
310+
"
311+
" foo :: Monad m
312+
" => Functor f
313+
" >>>>=> Int
314+
"
307315
" foo :: Int
308316
" -> Int
309317
" foo x
@@ -312,32 +320,36 @@ function! GetHaskellIndent()
312320
" :: Int
313321
" -> Int
314322
" foo x
315-
if l:prevline =~ '^\s*[-=]>' && l:line !~ '^\s*[-=]>'
316-
if s:isInBlock(l:hlstack)
317-
return match(l:prevline, '[^\s-=>]')
323+
if l:prevline =~ '^\s*[-=]>'
324+
if l:line =~ '^\s*[-=]>'
325+
return match(l:prevline, '[-=]')
318326
else
319-
let l:m = matchstr(l:line, '^\s*\zs\<\S\+\>\ze')
320-
let l:l = l:prevline
321-
let l:c = 1
322-
323-
while v:lnum != l:c
324-
" fun decl
325-
if l:l =~ ('^\s*' . l:m . '\(\s*::\|\n\s\+::\)')
326-
let l:s = match(l:l, l:m)
327-
if match(l:l, '\C^\s*\<default\>') > -1
328-
return l:s - 8
329-
else
330-
return l:s
327+
if s:isInBlock(l:hlstack)
328+
return match(l:prevline, '[^-=]')
329+
else
330+
let l:m = matchstr(l:line, '^\s*\zs\<\S\+\>\ze')
331+
let l:l = l:prevline
332+
let l:c = 1
333+
334+
while v:lnum != l:c
335+
" fun decl
336+
if l:l =~ ('^\s*' . l:m . '\(\s*::\|\n\s\+::\)')
337+
let l:s = match(l:l, l:m)
338+
if match(l:l, '\C^\s*\<default\>') > -1
339+
return l:s - 8
340+
else
341+
return l:s
342+
endif
343+
" empty line, stop looking
344+
elseif l:l =~ '^$'
345+
return 0
331346
endif
332-
" empty line, stop looking
333-
elseif l:l =~ '^$'
334-
return 0
335-
endif
336-
let l:c += 1
337-
let l:l = getline(v:lnum - l:c)
338-
endwhile
347+
let l:c += 1
348+
let l:l = getline(v:lnum - l:c)
349+
endwhile
339350

340-
return 0
351+
return 0
352+
endif
341353
endif
342354
endif
343355

0 commit comments

Comments
 (0)