[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/swift-mode 18ea989 134/496: Merge pull request #42 from ap
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/swift-mode 18ea989 134/496: Merge pull request #42 from ap4y/customizable_multiline_dot_statement |
Date: |
Sun, 29 Aug 2021 11:33:22 -0400 (EDT) |
branch: elpa/swift-mode
commit 18ea9896272745b9e151314ab7c386033c21c40c
Merge: 835c3d3 dd8f793
Author: Bozhidar Batsov <bozhidar.batsov@gmail.com>
Commit: Bozhidar Batsov <bozhidar.batsov@gmail.com>
Merge pull request #42 from ap4y/customizable_multiline_dot_statement
Make multi-line dot statement offset customisable value
---
swift-mode.el | 14 ++++++++++++++
test/indentation-tests.el | 31 +++++++++++++++++++++++++++++++
2 files changed, 45 insertions(+)
diff --git a/swift-mode.el b/swift-mode.el
index adea3e9..d6f2f24 100644
--- a/swift-mode.el
+++ b/swift-mode.el
@@ -53,6 +53,12 @@
:group 'swift
:type 'integerp)
+(defcustom swift-indent-multiline-dot-offset 2
+ "Defines the indentation offset for for multiline dot statement."
+ :group 'swift
+ :type 'integerp
+ :package-version '(swift-mode "0.3.0"))
+
(defcustom swift-repl-executable
"xcrun swift"
"Path to the Swift CLI."
@@ -266,6 +272,14 @@
(if (smie-rule-parent-p "case" "default")
(smie-rule-parent swift-indent-offset)))
+ ;; Apply swift-indent-multiline-dot-offset only if
+ ;; - dot is followed by newline, or
+ ;; - have at least one whitespace character before dot
+ (`(:before . ".")
+ (if (or (looking-at "[.][\n]")
+ (looking-back "[ \t\n]" 1 t))
+ (smie-rule-parent swift-indent-multiline-dot-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 d5dc4b4..c4c9e2a 100644
--- a/test/indentation-tests.el
+++ b/test/indentation-tests.el
@@ -58,6 +58,7 @@ values of customisable variables."
;; Bind customisable vars to default values for tests.
(swift-indent-offset 4)
(swift-indent-switch-case-offset 0)
+ (swift-indent-multiline-dot-offset 2)
,@var-bindings)
(with-temp-buffer
(insert ,before)
@@ -810,6 +811,36 @@ let json_ary = NSJSONSerialization
|.JSONObjectWithData(data, options: nil, error: &json_err) as
NSArray
")
+(check-indentation indents-multiline-expressions-to-user-defined-offset/1
+ "
+NSNotificationCenter.defaultCenter().
+|postNotificationName(foo, object: nil)
+" "
+NSNotificationCenter.defaultCenter().
+ |postNotificationName(foo, object: nil)
+"
+((swift-indent-multiline-dot-offset 4)))
+
+(check-indentation indents-multiline-expressions-to-user-defined-offset/2
+ "
+NSNotificationCenter.defaultCenter()
+|.postNotificationName(foo, object: nil)
+" "
+NSNotificationCenter.defaultCenter()
+ |.postNotificationName(foo, object: nil)
+"
+((swift-indent-multiline-dot-offset 4)))
+
+(check-indentation indents-multiline-expressions-to-user-defined-offset/3
+ "
+let json_ary = NSJSONSerialization
+ |.JSONObjectWithData(data, options: nil, error: &json_err) as
NSArray
+" "
+let json_ary = NSJSONSerialization
+ |.JSONObjectWithData(data, options: nil, error: &json_err) as
NSArray
+"
+((swift-indent-multiline-dot-offset 4)))
+
(check-indentation indents-type-annotations/1
"
typealias Foo = Bar<Foo.Baz, Foo>
- [nongnu] elpa/swift-mode d136303 076/496: Adding support for Swift REPL via comint-mode, (continued)
- [nongnu] elpa/swift-mode d136303 076/496: Adding support for Swift REPL via comint-mode, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 286c4b8 077/496: Merge pull request #21 from ap4y/feature_repl, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode e0fba71 083/496: repl -> REPL, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 48cbf55 088/496: Extend a bit installation instructions for package.el, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 7e77211 087/496: Remove redundant autoload, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode a092adc 091/496: Return default paragraph definitions., ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode c9c1271 089/496: Make flycheck work with multiple sources, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 4ac4ea3 098/496: Add font-lock for declaration expression with destructuring, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 6abb788 121/496: Add keywords header, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 07780b4 118/496: Merge pull request #30 from ap4y/syntactic_fontification, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 18ea989 134/496: Merge pull request #42 from ap4y/customizable_multiline_dot_statement,
ELPA Syncer <=
- [nongnu] elpa/swift-mode d42c53c 147/496: Use semantic smie function instead of regex for multi-line dot, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 34f0c95 152/496: Correct source argument extraction in flycheck checker, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 773219a 142/496: Treat default clause for case statement as a whole with colon in bnf, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode d7b13b0 150/496: Convert targeted sdk flycheck option from list to string, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode b0fea47 168/496: Fix eval-after-load problems when byte-compiled., ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode e859716 176/496: Merge pull request #75 from ap4y/test_against_24_4, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode f2b923e 178/496: Improve case statement grammar, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 75aa277 188/496: Add separate lexer rule for return type arrow symbol "->", prevent, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 1c4253b 191/496: Improve indentation for nested hash/array statements, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode ebc60c8 197/496: Make closure block in function argument close at the offset 0, ELPA Syncer, 2021/08/29