3 " Author: motemen <motemen@gmail.com>
5 " Last Change: 2007-07-25
7 " Modify g:haskell_indent_if and g:haskell_indent_case to
8 " change indentation for `if'(default 3) and `case'(default 5).
10 " > let g:haskell_indent_if = 2
12 if exists('b:did_indent')
18 if !exists('g:haskell_indent_if')
22 let g:haskell_indent_if = 3
25 if !exists('g:haskell_indent_case')
29 let g:haskell_indent_case = 5
32 setlocal indentexpr=GetHaskellIndent()
33 setlocal indentkeys=!^F,o,O
35 function! GetHaskellIndent()
36 let line = substitute(getline(getpos('.')[1] - 1), '\t', repeat(' ', &tabstop), 'g')
38 if line =~ '[!#$%&*+./<=>?@\\^|~-]$\|\<do$'
39 return match(line, '\s*where \zs\|\S') + &shiftwidth
43 return match(line, '\s*where \zs\|\S') + &shiftwidth
46 if line =~ '^\(instance\|class\).*\&.*where$'
53 let paren_end = getpos('.')
55 let paren_begin = getpos('.')
57 if paren_begin[1] != paren_end[1]
58 return paren_begin[2] - 1
63 let s = match(line, '\<if\>.*\&.*\zs\<then\>')
68 let s = match(line, '\<if\>')
70 return s + g:haskell_indent_if
74 let s = match(line, '\<do\s\+\zs[^{]\|\<where\s\+\zs\w\|\<let\s\+\zs\S\|^\s*\zs|\s')
79 let s = match(line, '\<case\>')
81 return s + g:haskell_indent_case
84 return match(line, '\S')