branch: elpa/haskell-tng-mode commit bc5c827954b052b7377e5bb4e39ebac6c70073e3 Author: Tseen She <ts33n....@gmail.com> Commit: Tseen She <ts33n....@gmail.com>
tuple indentation --- haskell-tng-smie.el | 9 +++++---- test/haskell-tng-indent-test.el | 3 +-- 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, 175 insertions(+), 10 deletions(-) diff --git a/haskell-tng-smie.el b/haskell-tng-smie.el index 267d63b..e1f3ccd 100644 --- a/haskell-tng-smie.el +++ b/haskell-tng-smie.el @@ -177,7 +177,7 @@ information, to aid in the creation of new rules." parent grand))))) (cond - ((smie-rule-parent-p "[") ",") + ((smie-rule-parent-p "[" "(") ",") ((or (smie-rule-parent-p "|") (and (smie-rule-parent-p "=") @@ -213,7 +213,7 @@ 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) + ((or "[" "(") 2) ("," (smie-rule-separator method)) ((or "$" "SYMID") (if (smie-rule-hanging-p) 2 (smie-rule-parent))) @@ -240,8 +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))) + ((or "[" "(") + (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 23ea996..7733261 100644 --- a/test/haskell-tng-indent-test.el +++ b/test/haskell-tng-indent-test.el @@ -14,8 +14,7 @@ ;; FIXME implement more indentation rules ;; -;; TODO tuples -;; TODO records +;; TODO records (resolve WLDO ambiguity) ;; TODO multiline type signatures ;; TODO if/then/else diff --git a/test/src/indentation.hs b/test/src/indentation.hs index 3bccfb8..488d17e 100644 --- a/test/src/indentation.hs +++ b/test/src/indentation.hs @@ -91,3 +91,18 @@ lists2 = [ lists3 = [ foo , bar ] + +tuples1 = ( foo + , bar + , ( blah + , blah + , blah ) + ) + +tuples2 = ( + foo +, bar +) + +tuples3 = ( foo , + bar ) diff --git a/test/src/indentation.hs.append.indent b/test/src/indentation.hs.append.indent index 00c2ade..8732e21 100644 --- a/test/src/indentation.hs.append.indent +++ b/test/src/indentation.hs.append.indent @@ -185,4 +185,34 @@ lists3 = [ foo , bar ] v 1 -v 1 \ No newline at end of file +v 1 +tuples1 = ( foo +1 v + , bar +1 v + , ( blah +2 1 v + , blah +1 2 v + , blah ) +2 v 1 + ) +v 1 2 + +v 1 2 +tuples2 = ( +1 v + foo +v 1 +, bar +v +) +v + +v +tuples3 = ( 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 b107c08..380ef7b 100644 --- a/test/src/indentation.hs.insert.indent +++ b/test/src/indentation.hs.insert.indent @@ -183,4 +183,34 @@ v lists3 = [ foo , 1 v bar ] -v 1 \ No newline at end of file +v 1 + +v 1 +tuples1 = ( 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 +tuples2 = ( +1 v + foo +1 v +, bar +v +) +v + +v +tuples3 = ( 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 3befa99..a85ba62 100644 --- a/test/src/indentation.hs.layout +++ b/test/src/indentation.hs.layout @@ -91,4 +91,19 @@ module Indentation where ;lists3 = [ foo , bar ] + +;tuples1 = ( foo + , bar + , ( blah + , blah + , blah ) + ) + +;tuples2 = ( + foo +;, bar +;) + +;tuples3 = ( foo , + bar ) } \ No newline at end of file diff --git a/test/src/indentation.hs.lexer b/test/src/indentation.hs.lexer index cf7d432..68e0020 100644 --- a/test/src/indentation.hs.lexer +++ b/test/src/indentation.hs.lexer @@ -91,4 +91,19 @@ VARID ; VARID = « VARID , VARID » + +; 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 70540ec..5f54fa1 100644 --- a/test/src/indentation.hs.reindent +++ b/test/src/indentation.hs.reindent @@ -183,4 +183,34 @@ v v 1 lists3 = [ foo , 1 v - bar ] \ No newline at end of file + bar ] +v 1 + +v 12 +tuples1 = ( 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 +tuples2 = ( +1 v + foo +v 1 +, bar +v +) +v + +v 1 +tuples3 = ( 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 16a638a..35c2bcf 100644 --- a/test/src/indentation.hs.sexps +++ b/test/src/indentation.hs.sexps @@ -90,5 +90,20 @@ )])) ((lists3) = ([ (foo) , - (bar) ])))))))))))))) + (bar) ])) + +((tuples1) = ( (foo) + , (bar) + , ( (blah) + , (blah) + , (blah) ) + )) + +((tuples2) = ( + (foo) +((, (bar)) +))) + +((tuples3) = ( (foo) , + (bar) )))))))))))))) ))) \ No newline at end of file diff --git a/test/src/indentation.hs.syntax b/test/src/indentation.hs.syntax index 2efb248..ce0322d 100644 --- a/test/src/indentation.hs.syntax +++ b/test/src/indentation.hs.syntax @@ -91,3 +91,18 @@ wwwwww _ (> > wwwwww _ ( www .> www )> +> +wwwwwww _ ( www> + . www> + . ( wwww> + . wwww> + . wwww )> + )> +> +wwwwwww _ (> + www> +. www> +)> +> +wwwwwww _ ( www .> + www )>