Skip to content

Commit

Permalink
ruby: use post-init func for smartparens config
Browse files Browse the repository at this point in the history
  • Loading branch information
syl20bnr committed Dec 11, 2015
1 parent 995a5a0 commit f20dfec
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions layers/+lang/ruby/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
ruby-test-mode
ruby-tools
rvm
smartparens
))
(if ruby-enable-enh-ruby-mode
(add-to-list 'ruby-packages 'enh-ruby-mode)
Expand Down Expand Up @@ -80,15 +81,7 @@
:config
(progn
(setq enh-ruby-deep-indent-paren nil
enh-ruby-hanging-paren-deep-indent-level 2)
(with-eval-after-load 'smartparens
(sp-with-modes 'enh-ruby-mode
(sp-local-pair
"{" "}"
:pre-handlers '(sp-ruby-pre-handler)
:post-handlers '(sp-ruby-post-handler
(spacemacs/smartparens-pair-newline-and-indent "RET"))
:suffix ""))))))
enh-ruby-hanging-paren-deep-indent-level 2))))

(defun ruby/post-init-evil-matchit ()
(dolist (hook '(ruby-mode-hook enh-ruby-mode-hook))
Expand Down Expand Up @@ -201,13 +194,7 @@
(progn
(spacemacs/set-leader-keys-for-major-mode 'ruby-mode
"'" 'ruby-toggle-string-quotes
"{" 'ruby-toggle-block)
(with-eval-after-load 'smartparens
(sp-with-modes 'ruby-mode
(sp-local-pair "{" "}"
:pre-handlers '(sp-ruby-pre-handler)
:post-handlers '(sp-ruby-post-handler (spacemacs/smartparens-pair-newline-and-indent "RET"))
:suffix ""))))))
"{" 'ruby-toggle-block))))

(defun ruby/init-ruby-tools ()
(use-package ruby-tools
Expand Down Expand Up @@ -255,3 +242,14 @@
(setq rspec-use-rvm t)
(spacemacs/add-to-hooks 'rvm-activate-corresponding-ruby
'(ruby-mode-hook enh-ruby-mode-hook)))))

(defun ruby/post-init-smartparens ()
(spacemacs|use-package-add-hook smartparens
:post-config
(sp-with-modes (if ruby-enable-enh-ruby-mode 'enh-ruby-mode 'ruby-mode)
(sp-local-pair
"{" "}"
:pre-handlers '(sp-ruby-pre-handler)
:post-handlers '(sp-ruby-post-handler
(spacemacs/smartparens-pair-newline-and-indent "RET"))
:suffix ""))))

0 comments on commit f20dfec

Please sign in to comment.