branch: elpa/swift-mode commit 4286ff9d8f1765605c6252a6b1d85d753f13f8c8 Merge: c664fc2 9b6f599 Author: Bozhidar Batsov <bozhidar.bat...@gmail.com> Commit: Bozhidar Batsov <bozhidar.bat...@gmail.com>
Merge pull request #52 from ap4y/fix_47 Fix 47 --- swift-mode.el | 9 ++++++++- test/indentation-tests.el | 11 +++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/swift-mode.el b/swift-mode.el index b06ff2d..4cce2e1 100644 --- a/swift-mode.el +++ b/swift-mode.el @@ -188,7 +188,8 @@ "<<" ">>"))) (defvar swift-smie--decl-specifier-regexp - (regexp-opt '("class" "mutating" "override" "static" "unowned" "weak"))) + (rx (? (or "class" "mutating" "override" "static" "unowned" "weak")) + (* space) "func")) (defun swift-smie--implicit-semi-p () (save-excursion @@ -286,6 +287,12 @@ (if (looking-at ".[\n]") (smie-rule-parent swift-indent-multiline-statement-offset))) + ;; Indent second line of the multi-line class + ;; definitions with swift-indent-offset + (`(:before . ",") + (if (smie-rule-parent-p "class") + swift-indent-offset)) + (`(:before . "if") (if (smie-rule-prev-p "else") (if (smie-rule-parent-p "{") diff --git a/test/indentation-tests.el b/test/indentation-tests.el index bb5286b..1c4b1fb 100644 --- a/test/indentation-tests.el +++ b/test/indentation-tests.el @@ -628,6 +628,17 @@ class Foo: Bar { } ") +(check-indentation indents-class-declaration/5 + " +class Foo: Foo, Bar, +|Baz { +} +" " +class Foo: Foo, Bar, + |Baz { +} +") + (check-indentation indents-func-declaration/1 " func Foo(a: String) {