Skip to content

Commit bafb78d

Browse files
committed
Add option g:haskell_indent_let_no_in
This addresses some of the grievances in neovimhaskell#85. Namely, we give users the option to change how indentation works with `let` statements. Current behavior: -- g:haskell_indent_let let x = 0 >>>>y = 0 let x = 0 in >>>>x -- g:haskell_indent_in let x = 0 >in x -- ??? (conflated with g:haskell_indent_let) let x = 0 >>>>x New behavior: -- g:haskell_indent_no_in let x = 0 >>>>x So for example, those who omit the 'in' on the first line and any 'let' on the second line can opt to have no indentaton: --- g:haskell_indent_no_in = 0 let x = 0 fooBar x
1 parent 9811f38 commit bafb78d

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

indent/haskell.vim

+18-1
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,18 @@ endif
3434
if !exists('g:haskell_indent_let')
3535
" let x = 0 in
3636
" >>>>x
37+
"
38+
" let x = 0
39+
" y = 1
3740
let g:haskell_indent_let = 4
3841
endif
3942

43+
if !exists('g:haskell_indent_let_no_in')
44+
" let x = 0
45+
" x
46+
let g:haskell_indent_let_no_in = 4
47+
endif
48+
4049
if !exists('g:haskell_indent_where')
4150
" where f :: Int -> Int
4251
" >>>>>>f x = x
@@ -208,6 +217,9 @@ function! GetHaskellIndent()
208217
"
209218
" let x = 1
210219
" >>>>y = 2
220+
"
221+
" let x = 1
222+
" y 2
211223
if l:prevline =~ '\C\<let\>\s\+.\+$'
212224
if l:line =~ '\C^\s*\<let\>'
213225
let l:s = match(l:prevline, '\C\<let\>')
@@ -219,11 +231,16 @@ function! GetHaskellIndent()
219231
if s:isSYN('haskellLet', v:lnum - 1, l:s + 1)
220232
return l:s + g:haskell_indent_in
221233
endif
222-
else
234+
elseif l:line =~ '\s=\s'
223235
let l:s = match(l:prevline, '\C\<let\>')
224236
if s:isSYN('haskellLet', v:lnum - 1, l:s + 1)
225237
return l:s + g:haskell_indent_let
226238
endif
239+
else
240+
let l:s = match(l:prevline, '\C\<let\>')
241+
if s:isSYN('haskellLet', v:lnum - 1, l:s + 1)
242+
return l:s + g:haskell_indent_let_no_in
243+
endif
227244
endif
228245
endif
229246

0 commit comments

Comments
 (0)