Skip to content

Commit a63be55

Browse files
committed
Use shiftwidth if where-indentation is not enabled
If indent_{before,after_bare}_where are not set, the current shiftwidth should be used, not the initial one (it could have changed).
1 parent e200d6b commit a63be55

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

indent/haskell.vim

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,12 @@ 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-
4640
if !exists('g:haskell_indent_where')
4741
" where f :: Int -> Int
4842
" >>>>>>f x = x
4943
let g:haskell_indent_where = 6
5044
endif
5145

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-
5846
if !exists('g:haskell_indent_do')
5947
" do x <- a
6048
" >>>y <- b
@@ -256,7 +244,7 @@ function! GetHaskellIndent()
256244
" >>foo
257245
"
258246
if l:prevline =~ '\C\<where\>\s*$'
259-
return match(l:prevline, '\S') + g:haskell_indent_after_bare_where
247+
return match(l:prevline, '\S') + get(g:, 'haskell_indent_after_bare_where', &shiftwidth)
260248
endif
261249

262250
" do
@@ -416,12 +404,17 @@ function! GetHaskellIndent()
416404

417405
" in foo
418406
" where bar
407+
"
408+
" or
409+
"
410+
" foo
411+
" >>where
419412
if l:line =~ '\C^\s*\<where\>'
420413
if match(l:prevline, '\C^\s\+in\s\+') == 0
421414
return match(l:prevline, 'in') - g:haskell_indent_in
422415
endif
423416

424-
return match(l:prevline, '\S') + g:haskell_indent_before_where
417+
return match(l:prevline, '\S') + get(g:, 'haskell_indent_before_where', &shiftwidth)
425418
endif
426419

427420
" let x = 1

0 commit comments

Comments
 (0)