Skip to content

Commit 67d33a2

Browse files
authored
fix indentation of multi-line type declaration (close #38) (#39)
1 parent 16c5e41 commit 67d33a2

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

indent/haskell.vim

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
" Filename: indent/haskell.vim
33
" Author: itchyny
44
" License: MIT License
5-
" Last Change: 2025/03/03 09:45:31.
5+
" Last Change: 2025/04/15 08:09:38.
66
" =============================================================================
77

88
if exists('b:did_indent')
@@ -80,6 +80,12 @@ function! GetHaskellIndent() abort
8080
return s:indent_eq()
8181
endif
8282

83+
if line =~# '\v\='
84+
if getline(v:lnum - 1) =~# '\v^\s*-\>'
85+
return indent(v:lnum - 1) - &shiftwidth
86+
endif
87+
endif
88+
8389
" }, ], )
8490
if line =~# '\v^\s*[})\]]'
8591
return s:indent_parenthesis()
@@ -264,6 +270,11 @@ function! GetHaskellIndent() abort
264270
return s:indent('', '\v^\s*\zs.*<let>', 0, -1)
265271
endif
266272

273+
" ::
274+
if nonblankline =~# '\v::\s*%(--.*)?$'
275+
return indent(v:lnum - 1) + &shiftwidth
276+
endif
277+
267278
if nonblankline =~# '::'
268279
return s:indent('', nonblankline =~# '\v,\s*%(--.*)?$' ? '\S' : '\v\{\s*\<\w+\s*::', 0, match(nonblankline, '\S'))
269280
endif

test/typesig/typesig.in.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
foo ::
2+
Int
3+
-> Int
4+
foo = bar

test/typesig/typesig.out.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
foo ::
2+
Int
3+
-> Int
4+
foo = bar

0 commit comments

Comments
 (0)