[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/haskell-tng-mode ddd0706 108/385: suggest next line indent
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/haskell-tng-mode ddd0706 108/385: suggest next line indentation |
Date: |
Tue, 5 Oct 2021 23:59:11 -0400 (EDT) |
branch: elpa/haskell-tng-mode
commit ddd070627ff8569a8c62631e87b6495163163914
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>
suggest next line indentation
---
haskell-tng-smie.el | 17 ++++++++++----
test/src/layout.hs.insert.indent | 6 ++---
test/src/medley.hs.insert.indent | 50 ++++++++++++++++++++--------------------
3 files changed, 40 insertions(+), 33 deletions(-)
diff --git a/haskell-tng-smie.el b/haskell-tng-smie.el
index 84f4be4..53dc63f 100644
--- a/haskell-tng-smie.el
+++ b/haskell-tng-smie.el
@@ -138,17 +138,24 @@
"Returns a list of alternative indentation levels for the
current line."
(save-excursion
- (let ((end (line-number-at-pos))
+ (let ((the-line (line-number-at-pos))
indents)
(when (re-search-backward haskell-tng:regexp:toplevel nil t)
- (while (< (line-number-at-pos) end)
+ (while (< (line-number-at-pos) the-line)
;; TODO add positions of WLDOS
;; TODO special cases for import (unless grammar handles it)
;; TODO special cases for multiple whitespaces (implies alignment)
- ;; TODO end +- 2
+ ;; TODO the-line +- 2
(push (current-indentation) indents)
- (forward-line))
- (-distinct (-sort '< indents))))))
+ (forward-line)))
+
+ ;; indentation of the next line is common for insert edits
+ (forward-line)
+ (forward-comment (point-max))
+ (when (not (eq the-line (line-number-at-pos)))
+ (push (current-indentation) indents))
+
+ (-distinct indents))))
(defun haskell-tng-smie:setup ()
(setq-local smie-indent-basic 2)
diff --git a/test/src/layout.hs.insert.indent b/test/src/layout.hs.insert.indent
index 9133f2a..18cd6ad 100644
--- a/test/src/layout.hs.insert.indent
+++ b/test/src/layout.hs.insert.indent
@@ -3,7 +3,7 @@ v
module AStack( Stack, push, pop, top, size ) where
. v
data Stack a = Empty
-. v
+. . v
| MkStack a (Stack a)
. v
@@ -17,7 +17,7 @@ v
size :: Stack a -> Int
v
size s = length (stkToLst s) where
-. v
+. v .
stkToLst Empty = []
. . v
stkToLst (MkStack x s) = x:xs where xs = stkToLst s
@@ -27,7 +27,7 @@ size s = length (stkToLst s) where
pop :: Stack a -> (a, Stack a)
v
pop (MkStack x s)
-. v
+. . v
= (x, case s of r -> i r where i x = x) -- (pop Empty) is an error
. . v
diff --git a/test/src/medley.hs.insert.indent b/test/src/medley.hs.insert.indent
index b077e30..2469ed6 100644
--- a/test/src/medley.hs.insert.indent
+++ b/test/src/medley.hs.insert.indent
@@ -7,7 +7,7 @@ v
-- | This file is a medley of various constructs and some corner cases
v
module Foo.Bar.Main
-. v
+. . v
( Wibble(..), Wobble(Wobb, (!!!)), Woo
. . v
-- * Operations
@@ -35,7 +35,7 @@ v
import qualified Options.Applicative as Opts
v
import qualified Options.Divisible -- wibble (wobble)
-. v
+. . v
as Div
v .
import qualified ProfFile.App hiding (as, hiding, qualified)
@@ -89,19 +89,19 @@ class Get a s where
. v
instance {-# OVERLAPS #-} Get a (a ': s) where
-. v
+. . v
get (Ext a _) = a
. . v
. v
instance {-# OVERLAPPABLE #-} Get a s => Get a (b ': s) where
-. v
+. . v
get (Ext _ xs) = get xs
. . v
. v
data Options = Options
-. v
+. . v
{ optionsReportType :: ReportType
. . v
, optionsProfFile :: Maybe FilePath
@@ -115,7 +115,7 @@ data Options = Options
v .
class (Eq a) => Ord a where
-. v
+. . v
(<), (<=), (>=), (>) :: a -> a -> Bool
. . v
max @Foo, min :: a -> a -> a
@@ -123,7 +123,7 @@ class (Eq a) => Ord a where
. v
instance (Eq a) => Eq (Tree a) where
-. v
+. . v
Leaf a == Leaf b = a == b
. . v
(Branch l1 r1) == (Branch l2 r2) = (l1==l2) && (r1==r2)
@@ -133,7 +133,7 @@ instance (Eq a) => Eq (Tree a) where
. v
data ReportType = Alloc -- ^ Report allocations, percent
-. v
+. . v
| Entries -- ^ Report entries, number
. v
| Time -- ^ Report time spent in closure, percent
@@ -147,7 +147,7 @@ data ReportType = Alloc -- ^ Report allocations, percent
v .
type family G a where
-. v
+. . v
G Int = Bool
. . v
G a = Char
@@ -155,7 +155,7 @@ type family G a where
. v
data Flobble = Flobble
-. v
+. . v
deriving (Eq) via (NonNegative (Large Int))
. v
deriving stock (Floo)
@@ -169,9 +169,9 @@ newtype Flobby = Flobby
v
foo ::
-. v
+.. v
Wibble -- wibble
-.v
+.v .
-> Wobble -- wobble
.. . v
-> Wobble -- wobble
@@ -191,7 +191,7 @@ v. .
v. .
newtype TestApp
-. v
+. . v
(logger :: TestLogger)
. v
(scribe :: TestScribe)
@@ -207,9 +207,9 @@ v .
optionsParser :: Opts.Parser Options
v
optionsParser = Options
-. v
- <$> (Opts.flag' Alloc (Opts.long "alloc" <> Opts.help "wibble")
. . v
+ <$> (Opts.flag' Alloc (Opts.long "alloc" <> Opts.help "wibble")
+. . . v
<|> Opts.flag' Entries (Opts.long "entry" <> Opts.help "wobble")
. . . v
<|> Opts.flag' Bytes (Opts.long "bytes" <> Opts.help "i'm a fish"))
@@ -217,9 +217,9 @@ optionsParser = Options
<*> optional
. . .v
(Opts.strArgument
-. . .. v
- (Opts.metavar "MY-FILE" <>
. . .. . v
+ (Opts.metavar "MY-FILE" <>
+. . .. .. v
Opts.help "meh"))
. . .v ..
@@ -229,9 +229,9 @@ type PhantomThing
v
type SomeApi =
-. v
+. v .
"thing" :> Capture "bar" Index :> QueryParam "wibble" Text
-. . v
+. . v .
:> QueryParam "wobble" Natural
. . v
:> Header TracingHeader
TracingId
@@ -239,9 +239,9 @@ type SomeApi =
:> ThingHeader
. . v
:> Get '[JSON] (The ReadResult)
-. . v
+. . . v
:<|> "thing" :> ReqBody '[JSON] Request
-. v . .
+. v . . .
:> Header TracingHeader TracingId
. . . v .
:> SpecialHeader
@@ -259,13 +259,13 @@ deriving newtype instance FromJSON Treble
v
foo = bar
-. v
+. . v
where baz = _
-. . v
+. . . v
-- checking that comments are ignored in layout
-. . v
+. . . v
-- and that a starting syntax entry is ok
-. . v
+. . . v
(+) = _
. . . v
- [nongnu] elpa/haskell-tng-mode ceaec13 098/385: groundwork for tab cycling, (continued)
- [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, 2021/10/06
- [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 <=
- [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
- [nongnu] elpa/haskell-tng-mode 6ade588 195/385: key bindings in compilation mode, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 144cabf 202/385: fix test assertions, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 04ebec6 204/385: third party integrations, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode aa9bbb7 216/385: add (broken) test coverage for consyms, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 5f423b9 100/385: some alts in the indentation test, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 50b53d3 114/385: tng compilation tests, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 36ece6d 117/385: low hanging fruit, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 489e4c9 124/385: document explicit export fontification bug, ELPA Syncer, 2021/10/06