branch: elpa/haskell-tng-mode commit 7f9afd2ac131c770f4dc98739448e5302d1c39cc Author: Tseen She <ts33n....@gmail.com> Commit: Tseen She <ts33n....@gmail.com>
list indentation --- haskell-tng-smie.el | 7 +++++++ test/haskell-tng-indent-test.el | 1 - test/src/indentation.hs | 15 +++++++++++++++ test/src/indentation.hs.append.indent | 32 +++++++++++++++++++++++++++++++- test/src/indentation.hs.insert.indent | 32 +++++++++++++++++++++++++++++++- test/src/indentation.hs.layout | 15 +++++++++++++++ test/src/indentation.hs.lexer | 15 +++++++++++++++ test/src/indentation.hs.reindent | 32 +++++++++++++++++++++++++++++++- test/src/indentation.hs.sexps | 17 ++++++++++++++++- test/src/indentation.hs.syntax | 15 +++++++++++++++ 10 files changed, 176 insertions(+), 5 deletions(-) diff --git a/haskell-tng-smie.el b/haskell-tng-smie.el index 9ffc506..267d63b 100644 --- a/haskell-tng-smie.el +++ b/haskell-tng-smie.el @@ -177,6 +177,8 @@ information, to aid in the creation of new rules." parent grand))))) (cond + ((smie-rule-parent-p "[") ",") + ((or (smie-rule-parent-p "|") (and (smie-rule-parent-p "=") (smie-rule-grandparent-p "data")) @@ -211,6 +213,8 @@ information, to aid in the creation of new rules." ((or "let" "do" "of" "=" "in" "->" "\\") 2) ("\\case" 2) ;; LambdaCase ("where" (if (smie-rule-parent-p "module") 0 2)) + ("[" 2) + ("," (smie-rule-separator method)) ((or "$" "SYMID") (if (smie-rule-hanging-p) 2 (smie-rule-parent))) )) @@ -236,6 +240,9 @@ information, to aid in the creation of new rules." (if (smie-rule-parent-p "=") (smie-rule-parent-column) (smie-rule-separator method))) + ("[" (when (smie-rule-hanging-p) + (smie-rule-parent))) + ("," (smie-rule-separator method)) (_ (when (smie-rule-parent-p "$" "SYMID") (smie-rule-parent))) )) diff --git a/test/haskell-tng-indent-test.el b/test/haskell-tng-indent-test.el index e1caec8..23ea996 100644 --- a/test/haskell-tng-indent-test.el +++ b/test/haskell-tng-indent-test.el @@ -14,7 +14,6 @@ ;; FIXME implement more indentation rules ;; -;; TODO lists ;; TODO tuples ;; TODO records ;; TODO multiline type signatures diff --git a/test/src/indentation.hs b/test/src/indentation.hs index 2b0db4e..3bccfb8 100644 --- a/test/src/indentation.hs +++ b/test/src/indentation.hs @@ -76,3 +76,18 @@ not_dollars = do data Wibble = Wibble Int | Wobble Int | Vibble Int + +lists1 = [ foo + , bar + , [ blah + , blah + , blah ] + ] + +lists2 = [ + foo +, bar +] + +lists3 = [ foo , + bar ] diff --git a/test/src/indentation.hs.append.indent b/test/src/indentation.hs.append.indent index 1392bd9..00c2ade 100644 --- a/test/src/indentation.hs.append.indent +++ b/test/src/indentation.hs.append.indent @@ -155,4 +155,34 @@ v | Vibble Int 1 v -v 1 \ No newline at end of file +v 1 +lists1 = [ foo +1 v + , bar +1 v + , [ blah +2 1 v + , blah +1 2 v + , blah ] +2 v 1 + ] +v 1 2 + +v 1 2 +lists2 = [ +1 v + foo +v 1 +, bar +v +] +v + +v +lists3 = [ foo , +1 v + bar ] +v 1 + +v 1 \ No newline at end of file diff --git a/test/src/indentation.hs.insert.indent b/test/src/indentation.hs.insert.indent index f7eedd9..b107c08 100644 --- a/test/src/indentation.hs.insert.indent +++ b/test/src/indentation.hs.insert.indent @@ -153,4 +153,34 @@ data Wibble = Wibble Int | Wobble Int 1 v | Vibble Int -v 1 \ No newline at end of file +1 v + +v 1 +lists1 = [ foo +1 v + , bar +2 1 v + , [ blah +2 1 v + , blah +2 3 1 v + , blah ] +2 1 v + ] +v 1 2 + +v 1 2 +lists2 = [ +1 v + foo +1 v +, bar +v +] +v + +v +lists3 = [ foo , +1 v + bar ] +v 1 \ No newline at end of file diff --git a/test/src/indentation.hs.layout b/test/src/indentation.hs.layout index b7767cd..3befa99 100644 --- a/test/src/indentation.hs.layout +++ b/test/src/indentation.hs.layout @@ -76,4 +76,19 @@ module Indentation where };data Wibble = Wibble Int | Wobble Int | Vibble Int + +;lists1 = [ foo + , bar + , [ blah + , blah + , blah ] + ] + +;lists2 = [ + foo +;, bar +;] + +;lists3 = [ foo , + bar ] } \ No newline at end of file diff --git a/test/src/indentation.hs.lexer b/test/src/indentation.hs.lexer index 5ff22ed..cf7d432 100644 --- a/test/src/indentation.hs.lexer +++ b/test/src/indentation.hs.lexer @@ -76,4 +76,19 @@ VARID } ; data CONID = CONID CONID | CONID CONID | CONID CONID + +; VARID = « VARID +, VARID +, « VARID +, VARID +, VARID » +» + +; VARID = « +VARID +; , VARID +; » + +; VARID = « VARID , +VARID » } diff --git a/test/src/indentation.hs.reindent b/test/src/indentation.hs.reindent index b6181e0..70540ec 100644 --- a/test/src/indentation.hs.reindent +++ b/test/src/indentation.hs.reindent @@ -153,4 +153,34 @@ data Wibble = Wibble Int 1 v | Wobble Int 1 v - | Vibble Int \ No newline at end of file + | Vibble Int +v 1 + +v 1 2 +lists1 = [ foo +1 v + , bar +2 v 1 + , [ blah +2 1 v + , blah +2 1 v + , blah ] +2 v 1 + ] +v 1 2 + +v 1 2 3 +lists2 = [ +1 v + foo +v 1 +, bar +v +] +v + +v 1 +lists3 = [ foo , +1 v + bar ] \ No newline at end of file diff --git a/test/src/indentation.hs.sexps b/test/src/indentation.hs.sexps index 32ad8d7..16a638a 100644 --- a/test/src/indentation.hs.sexps +++ b/test/src/indentation.hs.sexps @@ -75,5 +75,20 @@ )data (Wibble) = (Wibble) (Int) | (Wobble) (Int) - | (Vibble) (Int))))))))))))) + | (Vibble) (Int) + +((lists1) = ([ (foo) + , (bar) + , ([ (blah) + , (blah) + , (blah) ]) + ])) + +((lists2) = ([ + (foo) +((, (bar)) +)])) + +((lists3) = ([ (foo) , + (bar) ])))))))))))))) ))) \ No newline at end of file diff --git a/test/src/indentation.hs.syntax b/test/src/indentation.hs.syntax index 115fdcb..2efb248 100644 --- a/test/src/indentation.hs.syntax +++ b/test/src/indentation.hs.syntax @@ -76,3 +76,18 @@ wwwwwwwwwww _ ww> wwww wwwwww _ wwwwww www> _ wwwwww www> _ wwwwww www> +> +wwwwww _ ( www> + . www> + . ( wwww> + . wwww> + . wwww )> + )> +> +wwwwww _ (> + www> +. www> +)> +> +wwwwww _ ( www .> + www )>