branch: elpa/haskell-tng-mode commit 59354b6d831fcb8e8dda28a3fdee5cc728eb6ea4 Author: Tseen She <ts33n....@gmail.com> Commit: Tseen She <ts33n....@gmail.com>
support hanging type alignment --- haskell-tng-smie.el | 9 ++++++--- test/haskell-tng-indent-test.el | 2 -- test/src/indentation.hs.append.indent | 2 +- test/src/indentation.hs.insert.indent | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/haskell-tng-smie.el b/haskell-tng-smie.el index a3243e9..b5eefbf 100644 --- a/haskell-tng-smie.el +++ b/haskell-tng-smie.el @@ -299,10 +299,12 @@ information, to aid in the creation of new rules." "\\case" ;; LambdaCase "where" "let" "do" "of")))) 2) - ((and "::" (guard (smie-rule-hanging-p))) + ("::" (if haskell-tng-aligntypes `(column . ,(+ haskell-tng-typelead (current-column))) haskell-tng-typelead)) + ((and "=>" (guard (smie-rule-parent-p "::"))) + (haskell-tng--smie-rule-parent-column 3)) ("," (smie-rule-separator method)) ((or "SYMID" "CONSYM" "KINDSYM") (if (smie-rule-hanging-p) 2 (smie-rule-parent))) @@ -453,13 +455,14 @@ BEFORE is t if the line appears before the indentation." :backward-token #'haskell-tng--lexer-backward-token) ) -(defun haskell-tng--smie-rule-parent-column () +(defun haskell-tng--smie-rule-parent-column (&optional offset) "For use inside `smie-rules-function', use the column indentation as the parent. Note that `smie-rule-parent' may use relative values." + (setq offset (or offset 0)) (save-excursion (goto-char (cadr (smie-indent--parent))) - `(column . ,(current-column)))) + `(column . ,(+ offset (current-column))))) (defun haskell-tng--smie-ancestors (n) "A list of the Nth non-{identifier, matched paren, string} diff --git a/test/haskell-tng-indent-test.el b/test/haskell-tng-indent-test.el index 08d0851..6e6d913 100644 --- a/test/haskell-tng-indent-test.el +++ b/test/haskell-tng-indent-test.el @@ -14,9 +14,7 @@ ;; FIXME implement more indentation rules ;; -;; TODO multiline type signatures ;; TODO records of functions tests -;; TODO user config for typesig preference (incompatible versions) ;; TODO ImplicitParams in type signatures (without parens) ;; TODO if/then/else diff --git a/test/src/indentation.hs.append.indent b/test/src/indentation.hs.append.indent index 89c7a34..8252d25 100644 --- a/test/src/indentation.hs.append.indent +++ b/test/src/indentation.hs.append.indent @@ -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 694bb46..13e6dad 100644 --- a/test/src/indentation.hs.insert.indent +++ b/test/src/indentation.hs.insert.indent @@ -273,7 +273,7 @@ types2 :: (Monad m, MemberLogger m) v 1 types3 :: (Monad m, MonadReader Foo m) => -2 v 1 +1 v (?log :: HasLogger m) => 1 v a -> b -> c