[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/haskell-tng-mode 4e1f51c 170/385: indent is deriving aware
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/haskell-tng-mode 4e1f51c 170/385: indent is deriving aware |
Date: |
Tue, 5 Oct 2021 23:59:25 -0400 (EDT) |
branch: elpa/haskell-tng-mode
commit 4e1f51c9205e9b40e2bbb68ab5e71de54756c050
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>
indent is deriving aware
---
haskell-tng-smie.el | 21 ++++++++++++++-------
test/haskell-tng-indent-test.el | 3 ---
test/src/indentation.hs | 5 +++++
test/src/indentation.hs.append.indent | 10 ++++++++++
test/src/indentation.hs.insert.indent | 10 ++++++++++
test/src/indentation.hs.layout | 5 +++++
test/src/indentation.hs.lexer | 5 +++++
test/src/indentation.hs.reindent | 12 +++++++++++-
test/src/indentation.hs.sexps | 5 +++++
test/src/indentation.hs.syntax | 5 +++++
10 files changed, 70 insertions(+), 11 deletions(-)
diff --git a/haskell-tng-smie.el b/haskell-tng-smie.el
index b4af17e..15d27de 100644
--- a/haskell-tng-smie.el
+++ b/haskell-tng-smie.el
@@ -69,10 +69,11 @@
(id "':" infixexp) ;; DataKinds
(id "SYMID" infixexp))
- (adt
- ("data" id "=" cop))
- (cop
- (cop "|" cop))
+ (data
+ ("data" id "=" cons))
+ (cons
+ (id "deriving" list)
+ (cons "|" cons))
;; WLDOs
(wldo
@@ -164,13 +165,17 @@ information, to aid in the creation of new rules."
(grand (cadr parents))
(prev (save-excursion
(car (smie-indent-backward-token))))
+ (psexp (save-excursion
+ (caddr (haskell-tng:until
+ (smie-backward-sexp)
+ (bobp)))))
(next (save-excursion
(car (smie-indent-forward-token)))))
(when haskell-tng-smie:debug
(with-current-buffer haskell-tng-smie:debug
- (insert (format " ^^: %S\n ^: %S\n -1: %S\n +1: %S\n"
- grand parent prev next))))
+ (insert (format " ^^: %S\n ^: %S\n -1: %S\n -(: %S\n +1: %S\n"
+ grand parent prev psexp next))))
(cond
((or
@@ -181,12 +186,14 @@ information, to aid in the creation of new rules."
",")
((or (equal parent "|")
- ;; TODO not if there is a deriving keyword somewhere
(and (equal parent "=")
(equal grand "data")
(not (equal prev "}"))))
"|")
+ ((equal parent "deriving")
+ ";")
+
((member next '(";" "}"))
;; TODO we could do semantic indentation here
;;
diff --git a/test/haskell-tng-indent-test.el b/test/haskell-tng-indent-test.el
index da015fc..cd2e0a3 100644
--- a/test/haskell-tng-indent-test.el
+++ b/test/haskell-tng-indent-test.el
@@ -14,11 +14,8 @@
;; FIXME implement more indentation rules
;;
-;; TODO records
-;; TODO coproducts
;; TODO multiline type signatures
;; TODO if/then/else
-;; TODO data: one conid ~> record, multi ~> coproduct
;; TODO reindenting needs attention, it's all over the radar
diff --git a/test/src/indentation.hs b/test/src/indentation.hs
index b2de628..3a95061 100644
--- a/test/src/indentation.hs
+++ b/test/src/indentation.hs
@@ -87,6 +87,11 @@ data Record2 = Record2
, fieldB :: String
}
+data Record3 = Record3 String Text
+ deriving (Show)
+
+data Record4 = Record3 String Text deriving (Show)
+
lists1 = [ foo
, bar
, [ blah
diff --git a/test/src/indentation.hs.append.indent
b/test/src/indentation.hs.append.indent
index 1f9b5ee..c52975e 100644
--- a/test/src/indentation.hs.append.indent
+++ b/test/src/indentation.hs.append.indent
@@ -176,6 +176,16 @@ data Record2 = Record2
v 1
v 1
+data Record3 = Record3 String Text
+1 v
+ deriving (Show)
+v 1
+
+v 1
+data Record4 = Record3 String Text deriving (Show)
+v
+
+v
lists1 = [ foo
1 v
, bar
diff --git a/test/src/indentation.hs.insert.indent
b/test/src/indentation.hs.insert.indent
index 4ef4d09..e9936c4 100644
--- a/test/src/indentation.hs.insert.indent
+++ b/test/src/indentation.hs.insert.indent
@@ -176,6 +176,16 @@ data Record2 = Record2
v 1
v 1
+data Record3 = Record3 String Text
+2 v 1
+ deriving (Show)
+v 1
+
+v 1
+data Record4 = Record3 String Text deriving (Show)
+v
+
+v
lists1 = [ foo
1 v
, bar
diff --git a/test/src/indentation.hs.layout b/test/src/indentation.hs.layout
index 7e363b8..a252c8d 100644
--- a/test/src/indentation.hs.layout
+++ b/test/src/indentation.hs.layout
@@ -87,6 +87,11 @@ module Indentation where
, fieldB :: String
}
+;data Record3 = Record3 String Text
+ deriving (Show)
+
+;data Record4 = Record3 String Text deriving (Show)
+
;lists1 = [ foo
, bar
, [ blah
diff --git a/test/src/indentation.hs.lexer b/test/src/indentation.hs.lexer
index 16bbe91..cd8d2e8 100644
--- a/test/src/indentation.hs.lexer
+++ b/test/src/indentation.hs.lexer
@@ -87,6 +87,11 @@ VARID :: CONID
, VARID :: CONID
»
+; data CONID = CONID CONID CONID
+deriving « CONID »
+
+; data CONID = CONID CONID CONID deriving « CONID »
+
; VARID = « VARID
, VARID
, « VARID
diff --git a/test/src/indentation.hs.reindent b/test/src/indentation.hs.reindent
index aac52c2..af1c5a31 100644
--- a/test/src/indentation.hs.reindent
+++ b/test/src/indentation.hs.reindent
@@ -176,7 +176,17 @@ data Record2 = Record2
}
v 1
-v 2 1
+v 2 1
+data Record3 = Record3 String Text
+1 v
+ deriving (Show)
+v 1
+
+v 1
+data Record4 = Record3 String Text deriving (Show)
+v
+
+v 1
lists1 = [ foo
1 v
, bar
diff --git a/test/src/indentation.hs.sexps b/test/src/indentation.hs.sexps
index 952103e..ee7ba3c 100644
--- a/test/src/indentation.hs.sexps
+++ b/test/src/indentation.hs.sexps
@@ -87,6 +87,11 @@
, (fieldB) (::) (String)
}))
+(data (Record3) = ((Record3) (String) (Text)
+ (deriving) ((Show))))
+
+(data (Record4) = ((Record3) (String) (Text) (deriving) ((Show))))
+
((lists1) = ([ (foo)
, (bar)
, ([ (blah)
diff --git a/test/src/indentation.hs.syntax b/test/src/indentation.hs.syntax
index 4fbb203..7c8efad 100644
--- a/test/src/indentation.hs.syntax
+++ b/test/src/indentation.hs.syntax
@@ -87,6 +87,11 @@ wwww wwwwwww _ wwwwwww>
. wwwwww __ wwwwww>
)>
>
+wwww wwwwwww _ wwwwwww wwwwww wwww>
+ wwwwwwww (wwww)>
+>
+wwww wwwwwww _ wwwwwww wwwwww wwww wwwwwwww (wwww)>
+>
wwwwww _ ( www>
. www>
. ( wwww>
- [nongnu] elpa/haskell-tng-mode adb3c50 143/385: better insert indentation suggestions, (continued)
- [nongnu] elpa/haskell-tng-mode adb3c50 143/385: better insert indentation suggestions, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode e79577e 132/385: match ghc source paths when compiling, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 8ec4807 145/385: somehow dropped font-lock-extend-region-multiline, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode d3a6a22 147/385: no todos in the test/src dir, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 85f20b1 154/385: indent coproducts, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 3dbb883 013/385: more progress on multiline type expansion, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode c6382e1 036/385: almost got it with imports, then I lost it..., ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode f3e3838 070/385: starting to transcribe the expression table, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode ceaec13 098/385: groundwork for tab cycling, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 8b6d545 178/385: split all the tests, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 4e1f51c 170/385: indent is deriving aware,
ELPA Syncer <=
- [nongnu] elpa/haskell-tng-mode 3ddafce 181/385: disambiguate -> during lexing, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 6b4dca0 189/385: note other build tools, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode cc657a8 197/385: support type alignment options, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode a7098e8 194/385: stylish haskell outputs failures, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 21fe2a0 221/385: fix broken test assertions, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 907255e 026/385: some namespacing, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode e7eaa38 077/385: some ideas for cabal, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode ddd0706 108/385: suggest next line indentation, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 7a8f714 139/385: indent back to the same level of `do', ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode ac55d33 134/385: interactive SMIE debugging, ELPA Syncer, 2021/10/06