Skip to content

Commit e200d6b

Browse files
committed
Add possibility of 2+2 space indentation for where
1 parent c992548 commit e200d6b

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

indent/haskell.vim

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,24 @@ if !exists('g:haskell_indent_let')
3737
let g:haskell_indent_let = 4
3838
endif
3939

40+
if !exists('g:haskell_indent_before_where')
41+
" f x = g
42+
" >>where
43+
let g:haskell_indent_before_where = &shiftwidth
44+
endif
45+
4046
if !exists('g:haskell_indent_where')
4147
" where f :: Int -> Int
4248
" >>>>>>f x = x
4349
let g:haskell_indent_where = 6
4450
endif
4551

52+
if !exists('g:haskell_indent_after_bare_where')
53+
" where
54+
" >>g y = x y
55+
let g:haskell_indent_after_bare_where = &shiftwidth
56+
endif
57+
4658
if !exists('g:haskell_indent_do')
4759
" do x <- a
4860
" >>>y <- b
@@ -243,12 +255,16 @@ function! GetHaskellIndent()
243255
" where
244256
" >>foo
245257
"
258+
if l:prevline =~ '\C\<where\>\s*$'
259+
return match(l:prevline, '\S') + g:haskell_indent_after_bare_where
260+
endif
261+
246262
" do
247263
" >>foo
248264
"
249265
" foo =
250266
" >>bar
251-
if l:prevline =~ '\C\(\<where\>\|\<do\>\|=\)\s*$'
267+
if l:prevline =~ '\C\(\<do\>\|=\)\s*$'
252268
return match(l:prevline, '\S') + &shiftwidth
253269
endif
254270

@@ -405,7 +421,7 @@ function! GetHaskellIndent()
405421
return match(l:prevline, 'in') - g:haskell_indent_in
406422
endif
407423

408-
return match(l:prevline, '\S') + &shiftwidth
424+
return match(l:prevline, '\S') + g:haskell_indent_before_where
409425
endif
410426

411427
" let x = 1

0 commit comments

Comments
 (0)