branch: elpa/smartparens commit 8de43d7d5853010b05feefcfdf8ab526482ac1b9 Merge: 920742d42c df74098a01 Author: Matus Goljer <matus.gol...@gmail.com> Commit: GitHub <nore...@github.com>
Merge pull request #1227 from woolsweater/swift-ts-mode Add config for 'swift-ts-mode' --- smartparens-config.el | 3 ++- smartparens-swift.el | 12 +++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/smartparens-config.el b/smartparens-config.el index e66ef059b4..03f02525bf 100644 --- a/smartparens-config.el +++ b/smartparens-config.el @@ -159,7 +159,8 @@ ID, ACTION, CONTEXT." (eval-after-load 'rust-ts-mode '(require 'smartparens-rust)) (eval-after-load 'rustic '(require 'smartparens-rust)) (eval-after-load 'scala-mode '(require 'smartparens-scala)) -(eval-after-load 'swift-mode '(require 'smartparens-swift)) +(--each '(swift-mode swift-ts-mode) + (eval-after-load it '(require 'smartparens-swift))) (eval-after-load 'tex-mode '(require 'smartparens-latex)) (eval-after-load 'text-mode '(require 'smartparens-text)) (eval-after-load 'tuareg '(require 'smartparens-ml)) diff --git a/smartparens-swift.el b/smartparens-swift.el index a1efab109d..fc0166b77d 100644 --- a/smartparens-swift.el +++ b/smartparens-swift.el @@ -28,8 +28,8 @@ ;;; Commentary: -;; This file provides some additional configuration for Swift. To use -;; it, simply add: +;; This file provides some additional configuration for Swift. To use it in +;; conjunction with either `swift-mode' or `swift-ts-mode', simply add: ;; ;; (require 'smartparens-config) ;; @@ -46,6 +46,7 @@ (require 'smartparens) (declare-function swift-mode "swift-mode") +(declare-function swift-ts-mode "swift-ts-mode") (defun sp-swift-skip-match-angle-bracket (_ms _mb me) "Non-nil if we should ignore the bracket as valid delimiter." @@ -102,15 +103,16 @@ ((eq action 'navigate) (and (not on-comparison) (not on-fn-return-type) (not on-range-operator)))))))) -(sp-with-modes '(swift-mode) +(sp-with-modes '(swift-mode swift-ts-mode) (sp-local-pair "<" ">" :when '(sp-swift-filter-angle-brackets) :skip-match 'sp-swift-skip-match-angle-bracket) (sp-local-pair "\"\"\"" "\"\"\"")) -;; Swift has no sexp suffices. This fixes slurping +;; Swift has no sexp suffixes. This fixes slurping ;; (|foo).bar -> (foo.bar) -(add-to-list 'sp-sexp-suffix (list #'swift-mode 'regexp "")) +(dolist (mode '(swift-mode swift-ts-mode)) + (add-to-list 'sp-sexp-suffix (list mode 'regexp ""))) (provide 'smartparens-swift)