[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/haskell-tng-mode cb0f3d2 082/385: starting indentation rul
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/haskell-tng-mode cb0f3d2 082/385: starting indentation rules |
Date: |
Tue, 5 Oct 2021 23:59:06 -0400 (EDT) |
branch: elpa/haskell-tng-mode
commit cb0f3d239f027ea7a5e532837f87c7f28398fd90
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>
starting indentation rules
---
haskell-tng-smie.el | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/haskell-tng-smie.el b/haskell-tng-smie.el
index 55832f6..07254bc 100644
--- a/haskell-tng-smie.el
+++ b/haskell-tng-smie.el
@@ -40,6 +40,7 @@
;; with a more complete grammar has been shown to be less than satisfactory,
;; therefore there is no reason to do more than is needed.
(defvar haskell-tng-smie:grammar
+ ;; see docs for `smie-prec2->grammar'
(smie-prec2->grammar
(smie-bnf->prec2
'((id)
@@ -57,6 +58,8 @@
(id "+" infixexp)
(id))
+ ;; TODO lexer should identify / normalise ids, consid, etc.
+
;; WLDOs
(wldo
("where" decls)
@@ -85,14 +88,26 @@
)))
-;; FIXME indentation rules
;;
https://www.gnu.org/software/emacs/manual/html_mono/elisp.html#SMIE-Indentation
;;
;; ideas for an indentation tester
;;
https://github.com/elixir-editors/emacs-elixir/blob/master/test/test-helper.el#L52-L63
-(defvar haskell-tng-smie:rules nil)
+(defun haskell-tng-smie:rules (method arg)
+ ;; see docs for `smie-rules-function'
+ ;; FIXME implement and test indentation
+ (pcase (cons method arg)
+ (`(:elem . basic) smie-indent-basic)
+ (`(,_ . ",") (smie-rule-separator method))
+ (`(:after . "=") smie-indent-basic)
+ (`(:before . ,(or `"(" `"{"))
+ (if (smie-rule-hanging-p) (smie-rule-parent)))
+ (`(:before . "if")
+ (and (not (smie-rule-bolp)) (smie-rule-prev-p "else")
+ (smie-rule-parent)))))
(defun haskell-tng-smie:setup ()
+ (setq-local smie-indent-basic 2)
+
(add-to-list
'after-change-functions
#'haskell-tng-layout:cache-invalidation)
@@ -103,7 +118,7 @@
(smie-setup
haskell-tng-smie:grammar
- haskell-tng-smie:rules
+ #'haskell-tng-smie:rules
:forward-token #'haskell-tng-lexer:forward-token
:backward-token #'haskell-tng-lexer:backward-token))
- [nongnu] elpa/haskell-tng-mode cb801b4 015/385: moar multiline type search, (continued)
- [nongnu] elpa/haskell-tng-mode cb801b4 015/385: moar multiline type search, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode de48840 030/385: multiline import anchors, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 5c50be0 044/385: remove redundant TODOs, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 174c63b 046/385: laying the foundations for SMIE, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 97ce717 058/385: improve the testing, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 2a2afee 064/385: cache invalidation and tests for layout invalidation, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 3ca869f 067/385: code reorganisation, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 0ffb885 071/385: a thought, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 79aeb82 076/385: most of the grammar, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 7eaef51 078/385: optimisation in the sexp test, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode cb0f3d2 082/385: starting indentation rules,
ELPA Syncer <=
- [nongnu] elpa/haskell-tng-mode cfbdae1 084/385: simplify the lexer assertion language, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 0c5acb7 087/385: lexer and grammar supports symid, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 6c520bc 093/385: fixes for type level lists, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode f085f16 097/385: indentation regression tests, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 01ea0b8 103/385: heuristic alternative indentation levels, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode c20ea4f 096/385: infix varid as symid, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode bfe859a 095/385: notes about lexers, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 0506391 109/385: module ... where indents to 0, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode d9bbcdd 111/385: next steps, ELPA Syncer, 2021/10/06
- [nongnu] elpa/haskell-tng-mode 6cf67bf 105/385: indentation can't handle mismatched parens, don't test for it, ELPA Syncer, 2021/10/06