2015-07-04 03:33:13 +00:00
|
|
|
;;; packages.el --- Ruby Layer packages File for Spacemacs
|
|
|
|
;;
|
|
|
|
;; Copyright (c) 2012-2014 Sylvain Benner
|
|
|
|
;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
|
|
|
|
;;
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
2015-04-19 03:40:24 +00:00
|
|
|
(setq ruby-packages
|
2015-10-15 20:52:43 +00:00
|
|
|
'(
|
|
|
|
bundler
|
|
|
|
company
|
|
|
|
evil-matchit
|
|
|
|
flycheck
|
|
|
|
robe
|
|
|
|
ruby-test-mode
|
|
|
|
ruby-tools))
|
2014-12-08 21:04:34 +00:00
|
|
|
|
2015-10-19 04:10:32 +00:00
|
|
|
(if ruby-enable-enh-ruby-mode
|
|
|
|
(add-to-list 'ruby-packages 'enh-ruby-mode)
|
|
|
|
(add-to-list 'ruby-packages 'ruby-mode))
|
|
|
|
|
2015-01-11 16:47:26 +00:00
|
|
|
(when ruby-version-manager
|
|
|
|
(add-to-list 'ruby-packages ruby-version-manager))
|
|
|
|
|
2014-12-08 21:04:34 +00:00
|
|
|
(defun ruby/init-rbenv ()
|
|
|
|
"Initialize RBENV mode"
|
|
|
|
(use-package rbenv
|
|
|
|
:defer t
|
2014-12-10 05:20:14 +00:00
|
|
|
:init (global-rbenv-mode)
|
2015-10-15 20:52:43 +00:00
|
|
|
:config (dolist (hook '(ruby-mode-hook enh-ruby-mode-hook))
|
|
|
|
(add-hook hook (lambda () (rbenv-use-corresponding))))))
|
2015-01-11 16:47:26 +00:00
|
|
|
|
|
|
|
(defun ruby/init-rvm ()
|
|
|
|
"Initialize RVM mode"
|
|
|
|
(use-package rvm
|
|
|
|
:defer t
|
|
|
|
:init (rvm-use-default)
|
2015-10-15 20:52:43 +00:00
|
|
|
:config (dolist (hook '(ruby-mode-hook enh-ruby-mode-hook))
|
|
|
|
(add-hook hook
|
|
|
|
(lambda () (rvm-activate-corresponding-ruby))))))
|
|
|
|
|
|
|
|
(defun ruby/init-ruby-mode ()
|
|
|
|
(use-package ruby-mode
|
|
|
|
:defer t
|
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
(evil-leader/set-key-for-mode 'ruby-mode
|
|
|
|
"m'" 'ruby-toggle-string-quotes
|
|
|
|
"m{" 'ruby-toggle-block)
|
|
|
|
(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 "")))))
|
2014-12-08 21:04:34 +00:00
|
|
|
|
2015-02-21 03:47:12 +00:00
|
|
|
(defun ruby/init-enh-ruby-mode ()
|
2015-02-10 23:08:15 +00:00
|
|
|
"Initialize Ruby Mode"
|
2015-02-21 03:47:12 +00:00
|
|
|
(use-package enh-ruby-mode
|
2015-02-21 03:47:29 +00:00
|
|
|
:mode (("\\(Rake\\|Thor\\|Guard\\|Gem\\|Cap\\|Vagrant\\|Berks\\|Pod\\|Puppet\\)file\\'" . enh-ruby-mode)
|
2015-05-27 01:29:55 +00:00
|
|
|
("\\.\\(rb\\|rabl\\|ru\\|builder\\|rake\\|thor\\|gemspec\\|jbuilder\\)\\'" . enh-ruby-mode))
|
2015-07-03 16:38:52 +00:00
|
|
|
:interpreter "ruby"
|
2015-05-27 01:29:55 +00:00
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
(setq enh-ruby-deep-indent-paren nil
|
|
|
|
enh-ruby-hanging-paren-deep-indent-level 2)
|
2015-10-15 20:52:43 +00:00
|
|
|
(sp-with-modes 'enh-ruby-mode
|
2015-05-27 01:29:55 +00:00
|
|
|
(sp-local-pair "{" "}"
|
|
|
|
:pre-handlers '(sp-ruby-pre-handler)
|
|
|
|
:post-handlers '(sp-ruby-post-handler (spacemacs/smartparens-pair-newline-and-indent "RET"))
|
|
|
|
:suffix "")))))
|
2014-12-08 21:04:34 +00:00
|
|
|
|
2015-07-05 07:38:41 +00:00
|
|
|
(defun ruby/post-init-evil-matchit ()
|
2015-10-15 20:52:43 +00:00
|
|
|
(dolist (hook '(ruby-mode-hook enh-ruby-mode-hook))
|
|
|
|
(add-hook hook `turn-on-evil-matchit-mode)))
|
2015-07-05 07:38:41 +00:00
|
|
|
|
2015-04-11 02:23:16 +00:00
|
|
|
(defun ruby/post-init-flycheck ()
|
2015-10-15 20:52:43 +00:00
|
|
|
(spacemacs/add-flycheck-hook 'ruby-mode)
|
2015-08-28 11:02:20 +00:00
|
|
|
(spacemacs/add-flycheck-hook 'enh-ruby-mode))
|
2015-02-10 23:08:15 +00:00
|
|
|
|
|
|
|
(defun ruby/init-ruby-tools ()
|
2015-03-21 22:39:37 +00:00
|
|
|
(use-package ruby-tools
|
|
|
|
:defer t
|
|
|
|
:init
|
2015-10-15 20:52:43 +00:00
|
|
|
(dolist (hook '(ruby-mode-hook enh-ruby-mode-hook))
|
|
|
|
(add-hook hook 'ruby-tools-mode))
|
2015-03-21 22:39:37 +00:00
|
|
|
:config
|
2015-07-29 09:58:47 +00:00
|
|
|
(progn
|
|
|
|
(spacemacs|hide-lighter ruby-tools-mode)
|
2015-10-15 20:52:43 +00:00
|
|
|
(dolist (mode '(ruby-mode enh-ruby-mode))
|
2015-10-20 08:17:43 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode mode "mx" "ruby/text")
|
2015-10-15 20:52:43 +00:00
|
|
|
(evil-leader/set-key-for-mode mode
|
|
|
|
"mx\'" 'ruby-tools-to-single-quote-string
|
|
|
|
"mx\"" 'ruby-tools-to-double-quote-string
|
|
|
|
"mx:" 'ruby-tools-to-symbol)))))
|
2015-02-10 23:08:15 +00:00
|
|
|
|
|
|
|
(defun ruby/init-bundler ()
|
|
|
|
(use-package bundler
|
|
|
|
:defer t
|
2015-03-16 03:48:58 +00:00
|
|
|
:init
|
2015-10-15 20:52:43 +00:00
|
|
|
(dolist (mode '(ruby-mode enh-ruby-mode))
|
2015-10-20 08:17:43 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode mode "mb" "ruby/bundle")
|
2015-10-15 20:52:43 +00:00
|
|
|
(evil-leader/set-key-for-mode mode
|
|
|
|
"mbc" 'bundle-check
|
|
|
|
"mbi" 'bundle-install
|
|
|
|
"mbs" 'bundle-console
|
|
|
|
"mbu" 'bundle-update
|
|
|
|
"mbx" 'bundle-exec))))
|
2014-12-23 03:51:44 +00:00
|
|
|
|
2014-12-08 21:04:34 +00:00
|
|
|
(defun ruby/init-robe ()
|
|
|
|
"Initialize Robe mode"
|
|
|
|
(use-package robe
|
|
|
|
:defer t
|
2015-04-07 20:02:53 +00:00
|
|
|
:init
|
|
|
|
(progn
|
2015-10-15 20:52:43 +00:00
|
|
|
(dolist (hook '(ruby-mode-hook enh-ruby-mode-hook))
|
|
|
|
(add-hook hook 'robe-mode))
|
2015-04-07 20:02:53 +00:00
|
|
|
(when (configuration-layer/layer-usedp 'auto-completion)
|
2015-10-15 20:52:43 +00:00
|
|
|
(push 'company-robe company-backends-enh-ruby-mode)
|
|
|
|
(push 'company-robe company-backends-ruby-mode)))
|
2015-03-16 03:48:58 +00:00
|
|
|
:config
|
|
|
|
(progn
|
2015-03-21 22:41:31 +00:00
|
|
|
(spacemacs|hide-lighter robe-mode)
|
2015-10-15 20:52:43 +00:00
|
|
|
|
|
|
|
(dolist (mode '(ruby-mode enh-ruby-mode))
|
2015-10-20 08:17:43 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode mode "mg" "ruby/goto")
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "mh" "ruby/docs")
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "ms" "ruby/repl")
|
2015-10-15 20:52:43 +00:00
|
|
|
(evil-leader/set-key-for-mode mode
|
|
|
|
;; robe mode specific
|
|
|
|
"mgg" 'robe-jump
|
|
|
|
"mhd" 'robe-doc
|
|
|
|
"mrsr" 'robe-rails-refresh
|
|
|
|
;; inf-enh-ruby-mode
|
|
|
|
"msf" 'ruby-send-definition
|
|
|
|
"msF" 'ruby-send-definition-and-go
|
|
|
|
"msi" 'robe-start
|
|
|
|
"msr" 'ruby-send-region
|
|
|
|
"msR" 'ruby-send-region-and-go
|
|
|
|
"mss" 'ruby-switch-to-inf)))))
|
2014-12-08 21:04:34 +00:00
|
|
|
|
|
|
|
(defun ruby/init-ruby-test-mode ()
|
|
|
|
"Define keybindings for ruby test mode"
|
|
|
|
(use-package ruby-test-mode
|
2014-12-10 05:20:14 +00:00
|
|
|
:defer t
|
2015-10-15 20:52:43 +00:00
|
|
|
:init (dolist (hook '(ruby-mode-hook enh-ruby-mode-hook))
|
|
|
|
(add-hook hook 'ruby-test-mode))
|
2015-03-09 03:12:28 +00:00
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
(spacemacs|hide-lighter ruby-test-mode)
|
2015-10-15 20:52:43 +00:00
|
|
|
(dolist (mode '(ruby-mode enh-ruby-mode))
|
2015-10-20 08:17:43 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode mode "mt" "ruby/test")
|
2015-10-15 20:52:43 +00:00
|
|
|
(evil-leader/set-key-for-mode mode "mtb" 'ruby-test-run)
|
|
|
|
(evil-leader/set-key-for-mode mode "mtt" 'ruby-test-run-at-point)))))
|
2015-04-07 20:02:53 +00:00
|
|
|
|
|
|
|
(when (configuration-layer/layer-usedp 'auto-completion)
|
2015-04-09 03:57:22 +00:00
|
|
|
(defun ruby/post-init-company ()
|
2015-10-15 20:52:43 +00:00
|
|
|
(spacemacs|add-company-hook ruby-mode)
|
2015-05-27 01:29:55 +00:00
|
|
|
(spacemacs|add-company-hook enh-ruby-mode)
|
2015-10-15 20:52:43 +00:00
|
|
|
|
2015-09-29 05:07:57 +00:00
|
|
|
(with-eval-after-load 'company-dabbrev-code
|
2015-10-15 20:52:43 +00:00
|
|
|
(dolist (mode '(ruby-mode enh-ruby-mode))
|
|
|
|
(push mode company-dabbrev-code-modes)))))
|