[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/swift-mode 071cd18 249/496: Merge pull request #100 from u
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/swift-mode 071cd18 249/496: Merge pull request #100 from uk-ar/enable-pairing-for-curly-bracket |
Date: |
Sun, 29 Aug 2021 11:33:45 -0400 (EDT) |
branch: elpa/swift-mode
commit 071cd18f452744c981c4f09c2b18cf30393ab686
Merge: b4b56f6 86339ed
Author: Arthur Evstifeev <mail@ap4y.me>
Commit: Arthur Evstifeev <mail@ap4y.me>
Merge pull request #100 from uk-ar/enable-pairing-for-curly-bracket
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 c2c3c01 199/496: Improve support for optional types, (continued)
- [nongnu] elpa/swift-mode c2c3c01 199/496: Improve support for optional types, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode d6483e1 207/496: Add ?? to the lexer rule for operators, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 9e6c538 210/496: Correct DECSPEC regex and lexer rule, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 2c67d92 213/496: Fix indentation of the closure arguments inside parentheses, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 5a858c7 218/496: Improve indentation of the array and dictionary expressions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 195d040 227/496: Merge pull request #76 from ap4y/batch_smie_fixes, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode dbf48a1 232/496: Merge pull request #90 from nathankot/flycheck-framework-search-paths, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode e6f1a3c 237/496: More configurability for flycheck, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 3e8befa 238/496: Merge pull request #92 from apiology/more_flycheck_option_vars, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 31fb250 248/496: added elseguard to lexer, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 071cd18 249/496: Merge pull request #100 from uk-ar/enable-pairing-for-curly-bracket,
ELPA Syncer <=
- [nongnu] elpa/swift-mode 7cefd8c 255/496: Fix token for generics, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode c51eaf8 257/496: Fix token for ! & ?, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode ce816a8 270/496: Fix backward-sexp test by adding brackets, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 85e05ea 271/496: Merge pull request #105 from uk-ar/fix-move-by-sexp, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode befeb2a 017/496: Highlight bools and nil as constants, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 654d5e2 006/496: More work on font locking, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode c4943a8 025/496: Add to auto-mode-alist, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 0ad90f8 035/496: Fix a typo, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 19a61d9 022/496: fixup! Copy syntax table from rust-mode., ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 406f2ba 028/496: Mention Emacs version in readme, ELPA Syncer, 2021/08/29