branch: elpa/haskell-tng-mode commit cc657a8c186d429322fca3e3c58061a063d761c6 Author: Tseen She <ts33n....@gmail.com> Commit: Tseen She <ts33n....@gmail.com>
support type alignment options --- haskell-tng-smie.el | 13 ++++++---- test/haskell-tng-indent-test.el | 22 ++++++++++------- test/src/indentation-options.hs.append.indent | 6 ++--- test/src/indentation-options.hs.insert.indent | 6 ++--- ...entation-options.hs => indentation-options1.hs} | 7 ------ ...ns.hs => indentation-options1.hs.append.indent} | 15 +++++++----- ...ns.hs => indentation-options1.hs.insert.indent} | 15 ++++++------ ...entation-options.hs => indentation-options2.hs} | 11 ++++----- ...ndent => indentation-options2.hs.append.indent} | 26 ++++++++++---------- ...ndent => indentation-options2.hs.insert.indent} | 28 ++++++++++------------ test/src/indentation.hs.append.indent | 4 ++-- test/src/indentation.hs.insert.indent | 4 ++-- 12 files changed, 79 insertions(+), 78 deletions(-) diff --git a/haskell-tng-smie.el b/haskell-tng-smie.el index 9a61bed..a3243e9 100644 --- a/haskell-tng-smie.el +++ b/haskell-tng-smie.el @@ -54,7 +54,6 @@ ;; TODO autodetection of indent options -;; TODO implement haskell-tng-aligntypes (defcustom haskell-tng-aligntypes nil "Whether to align arrows to their parent :: declaration. @@ -68,7 +67,6 @@ foobar :: Monad m :type 'booleanp :group 'haskell-tng) -;; TODO implement haskell-tng-typelead (defcustom haskell-tng-typelead 3 "Leading spaces in a trailing type signature, relative to type arrows. For example 3 and 1 are respectively: @@ -301,7 +299,10 @@ information, to aid in the creation of new rules." "\\case" ;; LambdaCase "where" "let" "do" "of")))) 2) - ("::" 5) + ((and "::" (guard (smie-rule-hanging-p))) + (if haskell-tng-aligntypes + `(column . ,(+ haskell-tng-typelead (current-column))) + haskell-tng-typelead)) ("," (smie-rule-separator method)) ((or "SYMID" "CONSYM" "KINDSYM") (if (smie-rule-hanging-p) 2 (smie-rule-parent))) @@ -329,7 +330,11 @@ information, to aid in the creation of new rules." (smie-rule-separator method))) ((and (or "[" "(" "{") (guard (smie-rule-hanging-p))) (smie-rule-parent)) - ((and "=>" (guard (not (smie-rule-sibling-p)))) 2) + ((and "=>" (guard (smie-rule-parent-p "::"))) + (if haskell-tng-aligntypes + (haskell-tng--smie-rule-parent-column) + (smie-rule-parent))) + ("::" 2) ("," (smie-rule-separator method)) ;; TODO ; as a separator, might remove ad-hoc WLDO rules ((guard (smie-rule-parent-p "SYMID" "CONSYM" "KINDSYM")) diff --git a/test/haskell-tng-indent-test.el b/test/haskell-tng-indent-test.el index a4d662c..08d0851 100644 --- a/test/haskell-tng-indent-test.el +++ b/test/haskell-tng-indent-test.el @@ -47,17 +47,23 @@ (ert-deftest haskell-tng-append-indent-file-tests:indentation () (should (have-expected-append-indent (testdata "src/indentation.hs")))) -(ert-deftest haskell-tng-append-indent-file-tests:options () - (let ((haskell-tng-aligntypes t) - (haskell-tng-typelead 1)) - (should (have-expected-append-indent (testdata "src/indentation-options.hs"))))) +(ert-deftest haskell-tng-append-indent-file-tests:options1 () + (let ((haskell-tng-typelead 1)) + (should (have-expected-append-indent (testdata "src/indentation-options1.hs"))))) +(ert-deftest haskell-tng-append-indent-file-tests:options2 () + (let ((haskell-tng-typelead 1) + (haskell-tng-aligntypes t)) + (should (have-expected-append-indent (testdata "src/indentation-options2.hs"))))) (ert-deftest haskell-tng-insert-indent-file-tests:indentation () (should (have-expected-insert-indent (testdata "src/indentation.hs")))) -(ert-deftest haskell-tng-insert-indent-file-tests:options () - (let ((haskell-tng-aligntypes t) - (haskell-tng-typelead 1)) - (should (have-expected-insert-indent (testdata "src/indentation-options.hs"))))) +(ert-deftest haskell-tng-insert-indent-file-tests:options1 () + (let ((haskell-tng-typelead 1)) + (should (have-expected-insert-indent (testdata "src/indentation-options1.hs"))))) +(ert-deftest haskell-tng-insert-indent-file-tests:options2 () + (let ((haskell-tng-typelead 1) + (haskell-tng-aligntypes t)) + (should (have-expected-insert-indent (testdata "src/indentation-options2.hs"))))) ;; TODO reindenting needs attention, it's all over the radar ;; (ert-deftest haskell-tng-reindent-file-tests () diff --git a/test/src/indentation-options.hs.append.indent b/test/src/indentation-options.hs.append.indent index 6f0976c..36b9b7f 100644 --- a/test/src/indentation-options.hs.append.indent +++ b/test/src/indentation-options.hs.append.indent @@ -5,9 +5,9 @@ v v types4 :: -1 v +1 v ( Monad m ) -2 v1 +2 1 v => a 1 v2 -> b @@ -17,7 +17,7 @@ types4 :: 1 v2 types5 :: Monad m -1 v +1 v => (?log :: HasLogger m) 1 v => a diff --git a/test/src/indentation-options.hs.insert.indent b/test/src/indentation-options.hs.insert.indent index f119ceb..cdff89b 100644 --- a/test/src/indentation-options.hs.insert.indent +++ b/test/src/indentation-options.hs.insert.indent @@ -5,9 +5,9 @@ v v types4 :: -2 1 v +1 v ( Monad m ) -2 v1 +3 12 v => a 1 v2 -> b @@ -17,7 +17,7 @@ types4 :: v 12 types5 :: Monad m -2 1 v +1 v => (?log :: HasLogger m) 1 v => a diff --git a/test/src/indentation-options.hs b/test/src/indentation-options1.hs similarity index 59% copy from test/src/indentation-options.hs copy to test/src/indentation-options1.hs index 5b764fd..db22140 100644 --- a/test/src/indentation-options.hs +++ b/test/src/indentation-options1.hs @@ -6,10 +6,3 @@ types4 :: => a -> b -> c - -types5 :: Monad m - => (?log :: HasLogger m) - => a - -> b - -> c - diff --git a/test/src/indentation-options.hs b/test/src/indentation-options1.hs.append.indent similarity index 59% copy from test/src/indentation-options.hs copy to test/src/indentation-options1.hs.append.indent index 5b764fd..841deb0 100644 --- a/test/src/indentation-options.hs +++ b/test/src/indentation-options1.hs.append.indent @@ -1,15 +1,18 @@ -- | Indentation scenarios to test indentation options. +v module Indentation where +v +v types4 :: +1 v ( Monad m ) +2 v1 => a +1 v2 -> b +1 v2 -> c +1 v2 -types5 :: Monad m - => (?log :: HasLogger m) - => a - -> b - -> c - +1 v2 \ No newline at end of file diff --git a/test/src/indentation-options.hs b/test/src/indentation-options1.hs.insert.indent similarity index 59% copy from test/src/indentation-options.hs copy to test/src/indentation-options1.hs.insert.indent index 5b764fd..a2c1679 100644 --- a/test/src/indentation-options.hs +++ b/test/src/indentation-options1.hs.insert.indent @@ -1,15 +1,16 @@ -- | Indentation scenarios to test indentation options. +v module Indentation where +v +v types4 :: +1 v ( Monad m ) +2 v1 => a +1 v2 -> b +1 v2 -> c - -types5 :: Monad m - => (?log :: HasLogger m) - => a - -> b - -> c - +v 12 \ No newline at end of file diff --git a/test/src/indentation-options.hs b/test/src/indentation-options2.hs similarity index 71% rename from test/src/indentation-options.hs rename to test/src/indentation-options2.hs index 5b764fd..912ffe1 100644 --- a/test/src/indentation-options.hs +++ b/test/src/indentation-options2.hs @@ -1,15 +1,14 @@ -- | Indentation scenarios to test indentation options. module Indentation where -types4 :: - ( Monad m ) - => a - -> b - -> c - types5 :: Monad m => (?log :: HasLogger m) => a -> b -> c +types6 :: + ( Monad m ) + => a + -> b + -> c diff --git a/test/src/indentation-options.hs.append.indent b/test/src/indentation-options2.hs.append.indent similarity index 62% copy from test/src/indentation-options.hs.append.indent copy to test/src/indentation-options2.hs.append.indent index 6f0976c..8b50cd8 100644 --- a/test/src/indentation-options.hs.append.indent +++ b/test/src/indentation-options2.hs.append.indent @@ -4,20 +4,8 @@ module Indentation where v v -types4 :: -1 v - ( Monad m ) -2 v1 - => a -1 v2 - -> b -1 v2 - -> c -1 v2 - -1 v2 types5 :: Monad m -1 v +1 v => (?log :: HasLogger m) 1 v => a @@ -28,5 +16,15 @@ types5 :: Monad m 1 v 1 v +types6 :: +1 v + ( Monad m ) +2 v1 + => a +1 v2 + -> b +1 v2 + -> c +1 v2 -1 v \ No newline at end of file +1 v2 \ No newline at end of file diff --git a/test/src/indentation-options.hs.append.indent b/test/src/indentation-options2.hs.insert.indent similarity index 63% copy from test/src/indentation-options.hs.append.indent copy to test/src/indentation-options2.hs.insert.indent index 6f0976c..e77b0f2 100644 --- a/test/src/indentation-options.hs.append.indent +++ b/test/src/indentation-options2.hs.insert.indent @@ -4,20 +4,8 @@ module Indentation where v v -types4 :: -1 v - ( Monad m ) -2 v1 - => a -1 v2 - -> b -1 v2 - -> c -1 v2 - -1 v2 types5 :: Monad m -1 v +1 v => (?log :: HasLogger m) 1 v => a @@ -27,6 +15,14 @@ types5 :: Monad m -> c 1 v -1 v - -1 v \ No newline at end of file +v 1 +types6 :: +1 v + ( Monad m ) +2 v1 + => a +1 v2 + -> b +1 v2 + -> c +v 12 \ No newline at end of file diff --git a/test/src/indentation.hs.append.indent b/test/src/indentation.hs.append.indent index fe7b3c6..89c7a34 100644 --- a/test/src/indentation.hs.append.indent +++ b/test/src/indentation.hs.append.indent @@ -263,7 +263,7 @@ types1 :: 1 v 2 types2 :: (Monad m, MemberLogger m) -1 v +1 v => a 1 v -> b @@ -273,7 +273,7 @@ types2 :: (Monad m, MemberLogger m) 1 v types3 :: (Monad m, MonadReader Foo m) => -1 v +1 v (?log :: HasLogger m) => 1 v a -> b -> c diff --git a/test/src/indentation.hs.insert.indent b/test/src/indentation.hs.insert.indent index 82df418..694bb46 100644 --- a/test/src/indentation.hs.insert.indent +++ b/test/src/indentation.hs.insert.indent @@ -263,7 +263,7 @@ types1 :: v 1 2 types2 :: (Monad m, MemberLogger m) -2 1 v +1 v => a 1 v -> b @@ -273,7 +273,7 @@ types2 :: (Monad m, MemberLogger m) v 1 types3 :: (Monad m, MonadReader Foo m) => -2 v1 +2 v 1 (?log :: HasLogger m) => 1 v a -> b -> c