2015-04-19 03:40:24 +00:00
|
|
|
(setq ruby-packages
|
2014-12-08 21:04:34 +00:00
|
|
|
'(
|
2015-04-09 03:57:22 +00:00
|
|
|
bundler
|
2015-04-18 00:40:39 +00:00
|
|
|
company
|
2015-02-21 03:47:12 +00:00
|
|
|
enh-ruby-mode
|
2014-12-23 03:51:44 +00:00
|
|
|
flycheck
|
2014-12-08 21:04:34 +00:00
|
|
|
robe
|
2015-04-09 03:57:22 +00:00
|
|
|
ruby-test-mode
|
|
|
|
ruby-tools
|
2015-01-31 11:05:37 +00:00
|
|
|
yaml-mode))
|
2014-12-08 21:04:34 +00:00
|
|
|
|
2015-01-11 16:47:26 +00:00
|
|
|
(when ruby-version-manager
|
|
|
|
(add-to-list 'ruby-packages ruby-version-manager))
|
|
|
|
|
2015-01-31 11:05:37 +00:00
|
|
|
(when ruby-enable-ruby-on-rails-support
|
|
|
|
(add-to-list 'ruby-packages 'haml-mode)
|
|
|
|
(add-to-list 'ruby-packages 'feature-mode)
|
|
|
|
(add-to-list 'ruby-packages 'projectile-rails))
|
|
|
|
|
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-02-21 03:47:12 +00:00
|
|
|
:config (add-hook 'enh-ruby-mode-hook
|
2015-01-11 16:47:26 +00:00
|
|
|
(lambda () (rbenv-use-corresponding)))))
|
|
|
|
|
|
|
|
(defun ruby/init-rvm ()
|
|
|
|
"Initialize RVM mode"
|
|
|
|
(use-package rvm
|
|
|
|
:defer t
|
|
|
|
:init (rvm-use-default)
|
2015-02-21 03:47:12 +00:00
|
|
|
:config (add-hook 'enh-ruby-mode-hook
|
2015-01-11 16:47:26 +00:00
|
|
|
(lambda () (rvm-activate-corresponding-ruby)))))
|
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))
|
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
(setq enh-ruby-deep-indent-paren nil
|
|
|
|
enh-ruby-hanging-paren-deep-indent-level 2)
|
|
|
|
(sp-with-modes '(ruby-mode 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 "")))))
|
2014-12-08 21:04:34 +00:00
|
|
|
|
2015-04-11 02:23:16 +00:00
|
|
|
(defun ruby/post-init-flycheck ()
|
2015-02-21 03:47:12 +00:00
|
|
|
(add-hook 'enh-ruby-mode-hook 'flycheck-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
|
|
|
|
(add-hook 'enh-ruby-mode-hook 'ruby-tools-mode)
|
|
|
|
:config
|
|
|
|
(spacemacs|hide-lighter ruby-tools-mode)))
|
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
|
|
|
|
(progn
|
|
|
|
(evil-leader/set-key-for-mode 'enh-ruby-mode "mbc" 'bundle-check)
|
|
|
|
(evil-leader/set-key-for-mode 'enh-ruby-mode "mbi" 'bundle-install)
|
|
|
|
(evil-leader/set-key-for-mode 'enh-ruby-mode "mbs" 'bundle-console)
|
|
|
|
(evil-leader/set-key-for-mode 'enh-ruby-mode "mbu" 'bundle-update)
|
|
|
|
(evil-leader/set-key-for-mode 'enh-ruby-mode "mbx" 'bundle-exec))))
|
2014-12-23 03:51:44 +00:00
|
|
|
|
2015-01-31 11:05:37 +00:00
|
|
|
(defun ruby/init-projectile-rails ()
|
|
|
|
(use-package projectile-rails
|
|
|
|
:defer t
|
2015-03-16 03:48:58 +00:00
|
|
|
:init
|
|
|
|
(progn
|
2015-03-21 22:40:36 +00:00
|
|
|
(add-hook 'enh-ruby-mode-hook 'projectile-rails-on))
|
2015-03-16 03:48:58 +00:00
|
|
|
:config
|
|
|
|
(progn
|
2015-03-21 22:40:36 +00:00
|
|
|
(spacemacs|diminish projectile-rails-mode " ⇋" " RoR")
|
|
|
|
|
2015-03-16 03:48:58 +00:00
|
|
|
;; Find files
|
2015-05-14 03:25:36 +00:00
|
|
|
(evil-leader/set-key-for-mode 'enh-ruby-mode
|
|
|
|
"mrfa" 'projectile-rails-find-locale
|
|
|
|
"mrfc" 'projectile-rails-find-controller
|
|
|
|
"mrfe" 'projectile-rails-find-environment
|
|
|
|
"mrff" 'projectile-rails-find-feature
|
|
|
|
"mrfh" 'projectile-rails-find-helper
|
|
|
|
"mrfi" 'projectile-rails-find-initializer
|
|
|
|
"mrfj" 'projectile-rails-find-javascript
|
|
|
|
"mrfl" 'projectile-rails-find-lib
|
|
|
|
"mrfm" 'projectile-rails-find-model
|
|
|
|
"mrfn" 'projectile-rails-find-migration
|
|
|
|
"mrfo" 'projectile-rails-find-log
|
|
|
|
"mrfp" 'projectile-rails-find-spec
|
|
|
|
"mrfr" 'projectile-rails-find-rake-task
|
|
|
|
"mrfs" 'projectile-rails-find-stylesheet
|
|
|
|
"mrft" 'projectile-rails-find-test
|
|
|
|
"mrfu" 'projectile-rails-find-fixture
|
|
|
|
"mrfv" 'projectile-rails-find-view
|
|
|
|
"mrfy" 'projectile-rails-find-layout
|
|
|
|
"mrf@" 'projectile-rails-find-mailer
|
|
|
|
;; Goto file
|
|
|
|
"mrgc" 'projectile-rails-find-current-controller
|
|
|
|
"mrgd" 'projectile-rails-goto-schema
|
|
|
|
"mrge" 'projectile-rails-goto-seeds
|
|
|
|
"mrgh" 'projectile-rails-find-current-helper
|
|
|
|
"mrgj" 'projectile-rails-find-current-javascript
|
|
|
|
"mrgg" 'projectile-rails-goto-gemfile
|
|
|
|
"mrgm" 'projectile-rails-find-current-model
|
|
|
|
"mrgn" 'projectile-rails-find-current-migration
|
|
|
|
"mrgp" 'projectile-rails-find-current-spec
|
|
|
|
"mrgr" 'projectile-rails-goto-routes
|
|
|
|
"mrgs" 'projectile-rails-find-current-stylesheet
|
|
|
|
"mrgt" 'projectile-rails-find-current-test
|
|
|
|
"mrgu" 'projectile-rails-find-current-fixture
|
|
|
|
"mrgv" 'projectile-rails-find-current-view
|
|
|
|
"mrgz" 'projectile-rails-goto-spec-helper
|
|
|
|
"mrg." 'projectile-rails-goto-file-at-point
|
|
|
|
;; Rails external commands
|
|
|
|
"mrcc" 'projectile-rails-generate
|
|
|
|
"mri" 'projectile-rails-console
|
|
|
|
"mrr:" 'projectile-rails-rake
|
|
|
|
"mrxs" 'projectile-rails-server
|
|
|
|
;; Refactoring 'projectile-rails-mode
|
|
|
|
"mrRx" 'projectile-rails-extract-region)
|
2015-04-25 08:53:03 +00:00
|
|
|
;; Ex-commands
|
|
|
|
(evil-ex-define-cmd "A" 'projectile-toggle-between-implementation-and-test))))
|
2015-01-31 11:05:37 +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
|
|
|
|
(add-hook 'enh-ruby-mode-hook 'robe-mode)
|
|
|
|
(when (configuration-layer/layer-usedp 'auto-completion)
|
2015-04-30 03:54:30 +00:00
|
|
|
(push 'company-robe company-backends-enh-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-03-16 03:48:58 +00:00
|
|
|
;; robe mode specific
|
|
|
|
(evil-leader/set-key-for-mode 'enh-ruby-mode "mgg" 'robe-jump)
|
|
|
|
(evil-leader/set-key-for-mode 'enh-ruby-mode "mhd" 'robe-doc)
|
|
|
|
(evil-leader/set-key-for-mode 'enh-ruby-mode "mrsr" 'robe-rails-refresh)
|
|
|
|
;; inf-enh-ruby-mode
|
|
|
|
(evil-leader/set-key-for-mode 'enh-ruby-mode "msf" 'ruby-send-definition)
|
|
|
|
(evil-leader/set-key-for-mode 'enh-ruby-mode "msF" 'ruby-send-definition-and-go)
|
|
|
|
(evil-leader/set-key-for-mode 'enh-ruby-mode "msi" 'robe-start)
|
|
|
|
(evil-leader/set-key-for-mode 'enh-ruby-mode "msr" 'ruby-send-region)
|
|
|
|
(evil-leader/set-key-for-mode 'enh-ruby-mode "msR" 'ruby-send-region-and-go)
|
|
|
|
(evil-leader/set-key-for-mode 'enh-ruby-mode "mss" 'ruby-switch-to-inf))))
|
2014-12-08 21:04:34 +00:00
|
|
|
|
|
|
|
(defun ruby/init-yaml-mode ()
|
|
|
|
"Initialize YAML mode"
|
|
|
|
(use-package yaml-mode
|
2015-03-16 03:48:58 +00:00
|
|
|
:mode (("\\.\\(yml\\|yaml\\)\\'" . yaml-mode)
|
|
|
|
("Procfile\\'" . yaml-mode))
|
2014-12-08 21:04:34 +00:00
|
|
|
:config (add-hook 'yaml-mode-hook
|
|
|
|
'(lambda ()
|
2015-03-16 03:48:58 +00:00
|
|
|
(define-key yaml-mode-map "\C-m" 'newline-and-indent)))))
|
2014-12-08 21:04:34 +00:00
|
|
|
|
2015-01-31 11:05:37 +00:00
|
|
|
(defun ruby/init-feature-mode ()
|
|
|
|
"Initialize Cucumber feature mode"
|
|
|
|
(use-package feature-mode
|
|
|
|
:mode (("\\.feature\\'" . feature-mode))))
|
2014-12-08 21:04:34 +00:00
|
|
|
|
2015-04-03 22:02:00 +00:00
|
|
|
(defun ruby/init-haml-mode ()
|
|
|
|
(use-package haml-mode
|
|
|
|
:defer t))
|
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-04-15 15:13:11 +00:00
|
|
|
:init (add-hook 'enh-ruby-mode-hook 'ruby-test-mode)
|
2015-03-09 03:12:28 +00:00
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
(spacemacs|hide-lighter ruby-test-mode)
|
2015-04-15 15:13:11 +00:00
|
|
|
(evil-leader/set-key-for-mode 'enh-ruby-mode "mtb" 'ruby-test-run)
|
|
|
|
(evil-leader/set-key-for-mode 'enh-ruby-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-05-27 01:29:55 +00:00
|
|
|
(spacemacs|add-company-hook enh-ruby-mode)
|
2015-06-08 06:18:14 +00:00
|
|
|
(eval-after-load 'company-dabbrev-code
|
|
|
|
'(push 'enh-ruby-mode company-dabbrev-code-modes))))
|