diff --git a/indent/haskell.vim b/indent/haskell.vim index 54f244a..2d6a237 100644 --- a/indent/haskell.vim +++ b/indent/haskell.vim @@ -2,7 +2,7 @@ " Filename: indent/haskell.vim " Author: itchyny " License: MIT License -" Last Change: 2023/11/07 19:40:39. +" Last Change: 2024/08/04 15:46:49. " ============================================================================= if exists('b:did_indent') @@ -178,6 +178,10 @@ function! GetHaskellIndent() abort return match(line, '\v^\s*%(|.*)?\s*\zs') + &shiftwidth endif + if line =~# '\v\\\s*\s*[[:alnum:](\-\"''\[]' + return match(line, '\v\\\s*\s*\zs\S') + endif + if nonblankline =~# '\v^.*[^|]\|[^|].*\=' return s:after_guard() endif diff --git a/test/case/lambda_case_literal.in.hs b/test/case/lambda_case_literal.in.hs new file mode 100644 index 0000000..531a90e --- /dev/null +++ b/test/case/lambda_case_literal.in.hs @@ -0,0 +1,6 @@ +f = \case [] -> 0 +"one" -> 1 +'0':_ -> 0 +xs@('-':_) -> g $ read xs +where g = \case -1 -> -100 +_ -> -1 diff --git a/test/case/lambda_case_literal.out.hs b/test/case/lambda_case_literal.out.hs new file mode 100644 index 0000000..5e94da4 --- /dev/null +++ b/test/case/lambda_case_literal.out.hs @@ -0,0 +1,6 @@ +f = \case [] -> 0 + "one" -> 1 + '0':_ -> 0 + xs@('-':_) -> g $ read xs + where g = \case -1 -> -100 + _ -> -1 diff --git a/test/case/lambda_case_same_line.in.hs b/test/case/lambda_case_same_line.in.hs new file mode 100644 index 0000000..7398f42 --- /dev/null +++ b/test/case/lambda_case_same_line.in.hs @@ -0,0 +1,5 @@ +f = \case 1 -> 0 +2 -> 1 +x -> g x +where g = \ case -1 -> -1 +_ -> 3 diff --git a/test/case/lambda_case_same_line.out.hs b/test/case/lambda_case_same_line.out.hs new file mode 100644 index 0000000..1a98e99 --- /dev/null +++ b/test/case/lambda_case_same_line.out.hs @@ -0,0 +1,5 @@ +f = \case 1 -> 0 + 2 -> 1 + x -> g x + where g = \ case -1 -> -1 + _ -> 3