22" Filename: indent/haskell.vim
33" Author: itchyny
44" License: MIT License
5- " Last Change: 2021/08/04 19:27:55 .
5+ " Last Change: 2021/08/07 07:21:36 .
66" =============================================================================
77
88if exists (' b:did_indent' )
@@ -91,7 +91,11 @@ function! GetHaskellIndent() abort
9191 return 0
9292 endif
9393
94- if line = ~# ' \v^\s*,([^()[\]{}]*|\([^()[\]{}]*\)|\[[^()[\]{}]*\])*(\s*--.*)?$' && nonblankline = ~# ' \v^\s*,'
94+ let noparen = ' [^()[\]{}]'
95+ let noparen = ' %(' . noparen . ' +|\(' . noparen . ' *\)|\[' . noparen . ' *\])'
96+ let noparen = ' %(' . noparen . ' +|\(' . noparen . ' *\)|\[' . noparen . ' *\])*'
97+
98+ if line = ~# ' \v^\s*,' . noparen . ' (\s*--.*)?$' && nonblankline = ~# ' \v^\s*,'
9599 return match (nonblankline, ' ^\s*\zs,' )
96100 endif
97101
@@ -106,15 +110,15 @@ function! GetHaskellIndent() abort
106110 return match (nonblankline, ' ^\s*\zs--' )
107111 endif
108112
109- if nonblankline = ~# ' \v^\s*}?[^()[\]{}]*[([{]([^()[\]{}]*|\([^()[\]{}]*\)|\[[^()[\]{}]*\])* [-+/*\$&<>,]?(\s*--.*)?$'
113+ if nonblankline = ~# ' \v^\s*}?' . noparen . ' [([{] ' . noparen . ' [-+/*\$&<>,]?(\s*--.*)?$'
110114 if nonblankline = ~# ' \v[([{](\s*--.*)?$'
111115 return match (nonblankline, ' \v^\s*(<where>|.*<let>)?\s*\zs' ) + &shiftwidth
112116 elseif nonblankline = ~# ' \v[-+/*\$&<>,](\s*--.*)?$'
113- return match (nonblankline, ' \v^\s*}?[^()[\]{}]* (\[.*\|\s*\zs|[([{]\s*\zs)' )
117+ return match (nonblankline, ' \v^\s*}?' . noparen . ' (\[.*\|\s*\zs|[([{]\s*\zs)' )
114118 elseif nonblankline = ~# ' \v^[^[\]]*\[([^[\]]*|\[[^[\]]*\])*\|([^[\]]*|\[[^[\]]*\])*(\s*--.*)?$'
115119 return match (nonblankline, ' \v^[^[\]]*\[([^[\]]*|\[[^[\]]*\])*\zs\|' )
116120 else
117- return match (nonblankline, ' \v^\s*}?[^()[\]{}]* \zs[([{]' )
121+ return match (nonblankline, ' \v^\s*}?' . noparen . ' \zs[([{]' )
118122 endif
119123 endif
120124
@@ -187,7 +191,7 @@ function! GetHaskellIndent() abort
187191 return match (nonblankline, ' \S' )
188192 else
189193 return match (nonblankline, ' \v^\s*(<where>|.*<let>)?\s*\zs' ) +
190- \ (nonblankline = ~# ' \v(<where>|<let>)|^\s*\k+\s*\=.*([-+/*\$&<>]|`\k+`)(\s*--.*)?$|(\=|-\>)(\s*--.*)?$' ? &shiftwidth : 0 )
194+ \ (nonblankline = ~# ' \v(<where>|<let>)|^\s*\k+\s*' . noparen . ' \=.*([-+/*\$&<>]|`\k+`)(\s*--.*)?$|(\=|-\>)(\s*--.*)?$' ? &shiftwidth : 0 )
191195 endif
192196 endif
193197
0 commit comments