swift: various fixes
Remove Emacs column in README tables Update README headers Use post-init function instead of layer-usedp Clean stand-alone closing parentheses Replace deprecated evil-leader/set-key-for-mode
This commit is contained in:
parent
bc20b25300
commit
afca744880
|
@ -1,14 +1,15 @@
|
|||
#+TITLE: Swift contribution layer for Spacemacs
|
||||
#+HTML_HEAD_EXTRA: <link rel="stylesheet" type="text/css" href="../../../css/readtheorg.css" />
|
||||
|
||||
[[file:img/swift.png]]
|
||||
|
||||
* Table of Contens :TOC@4:
|
||||
- [[#description][Description]]
|
||||
- [[#install][Install]]
|
||||
- [[#usage-information][Usage information]]
|
||||
- [[#key-bindings][Key bindings]]
|
||||
- [[#swift-mode][swift-mode]]
|
||||
- [[#swift-repl-mode][swift-repl-mode]]
|
||||
* Table of Contents :TOC_4_org:noexport:
|
||||
- [[Description][Description]]
|
||||
- [[Install][Install]]
|
||||
- [[Usage information][Usage information]]
|
||||
- [[Key bindings][Key bindings]]
|
||||
- [[swift-mode][swift-mode]]
|
||||
- [[swift-repl-mode][swift-repl-mode]]
|
||||
|
||||
* Description
|
||||
This layer adds support for Apple's Swift programming language, used as a
|
||||
|
@ -33,32 +34,27 @@ On OS X:
|
|||
#+END_SRC
|
||||
|
||||
* Usage information
|
||||
|
||||
Unless configured by the user, the REPL will be invoked using the command ~xcrun
|
||||
swift~.
|
||||
|
||||
You can launch the REPL using the keybinding ~SPC m s s~ (or ~C-c C-z~).
|
||||
|
||||
The universal prefix ~SPC u~ (~C-u~) may be used to modify command invocation.
|
||||
|
||||
* Key bindings
|
||||
|
||||
** swift-mode
|
||||
|
||||
| Emacs | Evil | Description |
|
||||
|-------------------+-----------------------+------------------------|
|
||||
| [~C-u~] ~C-c C-z~ | [~SPC u~] ~SPC m s s~ | swift-mode-run-repl |
|
||||
| ~C-c C-f~ | ~SPC m s b~ | swift-mode-send-buffer |
|
||||
| ~C-c C-r~ | ~SPC m s r~ | swift-mode-send-region |
|
||||
| Key bindings | Description |
|
||||
|--------------+------------------------|
|
||||
| ~SPC m s s~ | swift-mode-run-repl |
|
||||
| ~SPC m s b~ | swift-mode-send-buffer |
|
||||
| ~SPC m s r~ | swift-mode-send-region |
|
||||
|
||||
Notes:
|
||||
|
||||
1. ~swift-mode-run-repl~ will run or switch to an existing REPL.
|
||||
2. To edit the command invocation, prefix with ~SPC u~ (or ~C-u~).
|
||||
3. Emacs key bindings in use are the those set by the package.
|
||||
|
||||
** swift-repl-mode
|
||||
|
||||
| Emacs | Evil | Description |
|
||||
|-----------+-------------+-----------------------------|
|
||||
| ~C-c C-z~ | ~SPC m s s~ | swift-repl-mode-switch-back |
|
||||
| Key bindings | Description |
|
||||
|--------------+-----------------------------|
|
||||
| ~SPC m s s~ | swift-repl-mode-switch-back |
|
||||
|
|
|
@ -16,21 +16,18 @@
|
|||
swift-mode
|
||||
))
|
||||
|
||||
(when (configuration-layer/layer-usedp 'syntax-checking)
|
||||
(defun swift/post-init-flycheck ()
|
||||
(spacemacs|use-package-add-hook flycheck
|
||||
:post-config
|
||||
(progn
|
||||
(add-to-list 'flycheck-checkers 'swift))))
|
||||
:post-config (add-to-list 'flycheck-checkers 'swift)))
|
||||
|
||||
(defun swift/init-swift-mode ()
|
||||
"Initialize swift-mode"
|
||||
(use-package swift-mode
|
||||
:mode ("\\.swift\\'" . swift-mode)
|
||||
:defer t
|
||||
:init
|
||||
(progn
|
||||
(spacemacs|advise-commands
|
||||
"store-initial-buffer-name" (swift-mode-run-repl) around
|
||||
(spacemacs|advise-commands "store-initial-buffer-name"
|
||||
(swift-mode-run-repl) around
|
||||
"Store current buffer bane in bufffer local variable,
|
||||
before activiting or switching to REPL."
|
||||
(let ((initial-buffer (current-buffer)))
|
||||
|
@ -38,40 +35,28 @@ before activiting or switching to REPL."
|
|||
(with-current-buffer swift-repl-buffer
|
||||
(setq swift-repl-mode-previous-buffer initial-buffer))))
|
||||
|
||||
;; (defadvice swift-mode-run-repl (around store-initial-buffer activate)
|
||||
;; "Store current buffer in a buffer-local variable."
|
||||
;; (let ((initial-buffer (current-buffer)))
|
||||
;; ad-do-it
|
||||
;; (with-current-buffer swift-repl-buffer
|
||||
;; (setq swift-repl-mode-previous-buffer initial-buffer))))
|
||||
|
||||
(defun spacemacs/swift-repl-mode-hook ()
|
||||
"Hook to run when starting an interactive swift mode repl"
|
||||
(make-variable-buffer-local 'swift-repl-mode-previous-buffer)
|
||||
)
|
||||
(spacemacs/add-to-hook 'swift-repl-mode-hook '(spacemacs/swift-repl-mode-hook))
|
||||
(make-variable-buffer-local 'swift-repl-mode-previous-buffer))
|
||||
(add-hook 'swift-repl-mode-hook 'spacemacs/swift-repl-mode-hook)
|
||||
|
||||
(defun spacemacs/swift-repl-mode-switch-back ()
|
||||
"Switch back to from REPL to editor."
|
||||
(interactive)
|
||||
(if swift-repl-mode-previous-buffer
|
||||
(switch-to-buffer-other-window swift-repl-mode-previous-buffer)
|
||||
(message "No previous buffer")))
|
||||
)
|
||||
(message "No previous buffer"))))
|
||||
:config
|
||||
(progn
|
||||
(evil-leader/set-key-for-mode 'swift-mode
|
||||
(spacemacs/set-leader-keys-for-major-mode 'swift-mode
|
||||
"msS" 'swift-mode-run-repl ; run or switch to an existing swift repl
|
||||
"mss" 'swift-mode-run-repl
|
||||
"msb" 'swift-mode-send-buffer
|
||||
"msr" 'swift-mode-send-region
|
||||
)
|
||||
"msr" 'swift-mode-send-region)
|
||||
|
||||
(with-eval-after-load 'swift-repl-mode-map
|
||||
;; Switch back to editor from REPL
|
||||
(evil-leader/set-key-for-mode 'swift-repl-mode
|
||||
(spacemacs/set-leader-keys-for-major-mode 'swift-repl-mode
|
||||
"mss" 'spacemacs/swift-repl-mode-switch-back)
|
||||
(define-key swift-repl-mode-map
|
||||
(kbd "C-c C-z") 'spacemacs/swift-repl-mode-switch-back)
|
||||
)
|
||||
)))
|
||||
(kbd "C-c C-z") 'spacemacs/swift-repl-mode-switch-back)))))
|
||||
|
|
Loading…
Reference in New Issue