[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/swift-mode 86339ed 247/496: Fix curly bracket's syntax tab
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/swift-mode 86339ed 247/496: Fix curly bracket's syntax table to enable electric-pair |
Date: |
Sun, 29 Aug 2021 11:33:45 -0400 (EDT) |
branch: elpa/swift-mode
commit 86339ed1a42d20f605be4cc23f3f1713fd39a9cc
Author: uk-ar <yuuki.ari@gmail.com>
Commit: uk-ar <yuuki.ari@gmail.com>
Fix curly bracket's syntax table to enable electric-pair
---
swift-mode.el | 37 +++++++++++++++++--------------------
1 file changed, 17 insertions(+), 20 deletions(-)
diff --git a/swift-mode.el b/swift-mode.el
index 19dd18a..d00b212 100644
--- a/swift-mode.el
+++ b/swift-mode.el
@@ -105,8 +105,9 @@
(top-level-st
("import" type)
(decl)
- ("ACCESSMOD" "class" class-decl-exp "{" class-level-sts "}")
- ("ACCESSMOD" "protocol" class-decl-exp "{" protocol-level-sts "}"))
+ ("ACCESSMOD" "class" class-decl-exp "class-{" class-level-sts "}")
+ ("ACCESSMOD" "protocol" class-decl-exp "protocol-{" protocol-level-sts
"}")
+ )
(class-level-sts (class-level-st) (class-level-st ";" class-level-st))
(class-level-st
@@ -144,8 +145,8 @@
(dot-exp (id "." id))
(method-call (dot-exp "(" method-args ")"))
- (method-args (method-arg) (method-arg "," method-arg))
- (method-arg (exp "," "{" closure "}") (exp))
+ (method-args (method-arg) (method-args "," method-args))
+ (method-arg (id "{" closure "}") (exp))
(exp (op-exp)
("[" decl-exps "]"))
@@ -251,7 +252,10 @@
(if (eolp) (forward-char 1) (forward-comment 1))
";")
- ((looking-at "{") (forward-char 1) "{")
+ ((looking-at "{") (forward-char 1)
+ (if (looking-back "\\(class\\|protocol\\) [^{]+{")
+ (concat (match-string 1) "-{")
+ "{"))
((looking-at "}") (forward-char 1) "}")
((looking-at ",") (forward-char 1) ",")
@@ -299,7 +303,10 @@
(swift-smie--implicit-semi-p))
";")
- ((eq (char-before) ?\{) (backward-char 1) "{")
+ ((eq (char-before) ?\{) (backward-char 1)
+ (if (looking-back "\\(class\\|protocol\\) [^{]+")
+ (concat (match-string 1) "-{")
+ "{"))
((eq (char-before) ?\}) (backward-char 1) "}")
((eq (char-before) ?,) (backward-char 1) ",")
@@ -354,6 +361,7 @@
((smie-rule-parent-p "=") 2)
;; Rule for the case statement.
((smie-rule-parent-p "case") swift-indent-offset)
+ ((smie-rule-parent-p ",") (smie-rule-parent swift-indent-offset))
;; Rule for the class definition.
((smie-rule-parent-p "class") (smie-rule-parent swift-indent-offset))))
@@ -414,6 +422,7 @@
((smie-rule-prev-p "->") swift-indent-offset)
((smie-rule-parent-p "[") (smie-rule-parent swift-indent-offset))
((smie-rule-parent-p "{") nil)
+ ((smie-rule-parent-p "class-{") nil)
(t (smie-rule-parent))))
(`(:after . "->") (smie-rule-parent swift-indent-offset))
))
@@ -744,20 +753,8 @@ You can send text to the REPL process from other buffers
containing source.
(modify-syntax-entry ?\) ")(" table)
(modify-syntax-entry ?\[ "(]" table)
(modify-syntax-entry ?\] ")[" table)
-
- ;; HACK: This is not a correct syntax table definition
- ;; for the braces, but it allows us disable smie indentation
- ;; based on syntax-table. Default behaviour doesn't work with
- ;; closures in method arguments. For example:
- ;;
- ;; foo.bar(10,
- ;; closure: {
- ;; })
- ;;
- ;; With enabled syntax table, smie doesn't respect closing brace, so
- ;; it's impossible to provide custom indentation rules
- (modify-syntax-entry ?\{ "w" table)
- (modify-syntax-entry ?\} "w" table)
+ (modify-syntax-entry ?\{ "(}" table)
+ (modify-syntax-entry ?\} "){" table)
table))
- [nongnu] elpa/swift-mode 250e8e4 172/496: Merge pull request #67 from jmibanez/fix-flycheck-and-byte-compilation-bug, (continued)
- [nongnu] elpa/swift-mode 250e8e4 172/496: Merge pull request #67 from jmibanez/fix-flycheck-and-byte-compilation-bug, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode a6267eb 189/496: Improve indentation for the function definitions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 782378c 214/496: Correct regex in lexer for the "default" keyword, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode c38b721 216/496: Support default values for arguments in function declaration, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 2cb54c9 222/496: Make grammar for if statement a bit more precise, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode b6bad10 225/496: Set minimum required version to 24.4, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 4a27477 230/496: Merge pull request #89 from uk-ar/fix-indent-in-trailing-closure, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 4289bd7 235/496: Fix implicit semicolon rule, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode a29398b 239/496: Fix half-open range operator, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 7f25806 241/496: Add as! operator, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 86339ed 247/496: Fix curly bracket's syntax table to enable electric-pair,
ELPA Syncer <=
- [nongnu] elpa/swift-mode 37cab39 263/496: Improve indentation for switch and class statements, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode cb7ba6f 245/496: Add an option for indent after hanging comma, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 0185315 274/496: Merge pull request #107 from uk-ar/fix-forward-list, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 27ec163 286/496: Merge pull request #113 from uk-ar/add-keyword-for-attribute, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode f43317e 290/496: Add MELPA badge in README, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode c73ce40 301/496: Update README.md about swift3-mode, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 7fc03bf 295/496: Merge pull request #119 from syohex/update-url, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 73abb98 292/496: Use cl-lib function instead of cl.el one, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 787658f 305/496: Update CONTRIBUTING.md, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 0e24233 307/496: Fix forward/backward-sexp inside comments, ELPA Syncer, 2021/08/29