2015-07-04 03:33:13 +00:00
|
|
|
;;; packages.el --- Ruby Layer packages File for Spacemacs
|
|
|
|
;;
|
2016-01-12 02:40:54 +00:00
|
|
|
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
|
2015-07-04 03:33:13 +00:00
|
|
|
;;
|
|
|
|
;; 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
|
2015-12-06 01:40:27 +00:00
|
|
|
chruby
|
2015-10-15 20:52:43 +00:00
|
|
|
company
|
2016-03-27 19:52:43 +00:00
|
|
|
(enh-ruby-mode :toggle ruby-enable-enh-ruby-mode)
|
2015-10-15 20:52:43 +00:00
|
|
|
evil-matchit
|
|
|
|
flycheck
|
2016-04-05 04:08:34 +00:00
|
|
|
ggtags
|
|
|
|
helm-gtags
|
2016-01-23 16:08:18 +00:00
|
|
|
popwin
|
2015-12-06 02:01:03 +00:00
|
|
|
rbenv
|
2015-10-15 20:52:43 +00:00
|
|
|
robe
|
2015-11-10 23:42:33 +00:00
|
|
|
rspec-mode
|
2015-09-08 23:03:42 +00:00
|
|
|
rubocop
|
2016-03-27 19:52:43 +00:00
|
|
|
(ruby-mode :location built-in :toggle (not ruby-enable-enh-ruby-mode))
|
2015-12-06 02:08:22 +00:00
|
|
|
ruby-test-mode
|
|
|
|
ruby-tools
|
2015-12-06 02:01:03 +00:00
|
|
|
rvm
|
2015-12-11 06:55:37 +00:00
|
|
|
smartparens
|
2016-02-29 19:24:52 +00:00
|
|
|
rake
|
2015-09-08 23:03:42 +00:00
|
|
|
))
|
2015-10-19 04:10:32 +00:00
|
|
|
|
2015-12-06 02:08:22 +00:00
|
|
|
(defun ruby/init-bundler ()
|
|
|
|
(use-package bundler
|
|
|
|
:defer t
|
2016-06-07 02:24:47 +00:00
|
|
|
:init (dolist (mode '(ruby-mode enh-ruby-mode))
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "mb" "ruby/bundle")
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode
|
|
|
|
"bc" 'bundle-check
|
|
|
|
"bi" 'bundle-install
|
|
|
|
"bs" 'bundle-console
|
|
|
|
"bu" 'bundle-update
|
|
|
|
"bx" 'bundle-exec
|
|
|
|
"bo" 'bundle-open))))
|
2015-12-06 02:08:22 +00:00
|
|
|
|
2016-05-30 02:39:21 +00:00
|
|
|
(defun ruby/post-init-company ()
|
|
|
|
(spacemacs|add-company-hook ruby-mode)
|
|
|
|
(spacemacs|add-company-hook enh-ruby-mode)
|
|
|
|
(with-eval-after-load 'company-dabbrev-code
|
|
|
|
(dolist (mode '(ruby-mode enh-ruby-mode))
|
|
|
|
(push mode company-dabbrev-code-modes))))
|
2015-12-06 02:08:22 +00:00
|
|
|
|
2015-12-06 01:40:27 +00:00
|
|
|
(defun ruby/init-chruby ()
|
2015-07-14 12:38:27 +00:00
|
|
|
(use-package chruby
|
2016-01-03 14:12:56 +00:00
|
|
|
:if (equal ruby-version-manager 'chruby)
|
2016-03-04 09:57:22 +00:00
|
|
|
:commands chruby-use-corresponding
|
2015-07-14 12:38:27 +00:00
|
|
|
:defer t
|
2016-06-07 02:24:47 +00:00
|
|
|
:init (spacemacs/add-to-hooks 'chruby-use-corresponding
|
|
|
|
'(ruby-mode-hook enh-ruby-mode-hook))))
|
2015-07-14 12:38:27 +00:00
|
|
|
|
2015-02-21 03:47:12 +00:00
|
|
|
(defun ruby/init-enh-ruby-mode ()
|
|
|
|
(use-package enh-ruby-mode
|
2016-02-24 13:40:25 +00:00
|
|
|
:mode (("Appraisals\\'" . enh-ruby-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"
|
2016-08-13 13:43:37 +00:00
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(spacemacs|define-jump-handlers enh-ruby-mode)
|
|
|
|
(setq enh-ruby-deep-indent-paren nil
|
|
|
|
enh-ruby-hanging-paren-deep-indent-level 2))))
|
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 ()
|
2016-01-27 20:08:25 +00:00
|
|
|
(spacemacs/add-flycheck-hook 'ruby-mode)
|
|
|
|
(spacemacs/add-flycheck-hook 'enh-ruby-mode))
|
2015-02-10 23:08:15 +00:00
|
|
|
|
2016-04-05 04:08:34 +00:00
|
|
|
(defun ruby/post-init-ggtags ()
|
2016-08-15 19:24:44 +00:00
|
|
|
(add-hook 'ruby-mode-local-vars-hook #'spacemacs/ggtags-mode-enable))
|
2016-04-05 04:08:34 +00:00
|
|
|
|
|
|
|
(defun ruby/post-init-helm-gtags ()
|
|
|
|
(spacemacs/helm-gtags-define-keys-for-mode 'ruby-mode))
|
|
|
|
|
2016-01-23 16:08:18 +00:00
|
|
|
(defun ruby/post-init-popwin ()
|
|
|
|
(push '("*rspec-compilation*" :dedicated t :position bottom :stick t :noselect t :height 0.4)
|
2016-03-05 19:54:17 +00:00
|
|
|
popwin:special-display-config)
|
|
|
|
(push '("*rake-compilation*" :dedicated t :position bottom :stick t :noselect t :height 0.4)
|
2016-01-23 16:08:18 +00:00
|
|
|
popwin:special-display-config))
|
|
|
|
|
2015-12-06 02:08:22 +00:00
|
|
|
(defun ruby/init-rbenv ()
|
|
|
|
(use-package rbenv
|
2016-01-03 14:12:56 +00:00
|
|
|
:if (equal ruby-version-manager 'rbenv)
|
2015-03-21 22:39:37 +00:00
|
|
|
:defer t
|
2016-06-07 02:24:47 +00:00
|
|
|
:init (spacemacs/add-to-hooks 'spacemacs//enable-rbenv
|
|
|
|
'(ruby-mode-hook enh-ruby-mode-hook))))
|
2014-12-23 03:51:44 +00:00
|
|
|
|
2014-12-08 21:04:34 +00:00
|
|
|
(defun ruby/init-robe ()
|
|
|
|
(use-package robe
|
|
|
|
:defer t
|
2015-04-07 20:02:53 +00:00
|
|
|
:init
|
|
|
|
(progn
|
2016-01-26 16:31:15 +00:00
|
|
|
(spacemacs/register-repl 'robe 'robe-start "robe")
|
2015-10-15 20:52:43 +00:00
|
|
|
(dolist (hook '(ruby-mode-hook enh-ruby-mode-hook))
|
|
|
|
(add-hook hook 'robe-mode))
|
2016-05-23 16:17:05 +00:00
|
|
|
(when (configuration-layer/package-usedp 'company)
|
2015-10-15 20:52:43 +00:00
|
|
|
(push 'company-robe company-backends-enh-ruby-mode)
|
2016-08-13 13:43:37 +00:00
|
|
|
(push 'company-robe company-backends-ruby-mode))
|
|
|
|
(spacemacs/add-to-hooks 'robe-jump
|
|
|
|
'(spacemacs-jump-handlers-ruby-mode
|
|
|
|
spacemacs-jump-handlers-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-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-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode
|
2016-01-26 16:31:15 +00:00
|
|
|
"'" 'robe-start
|
2015-10-15 20:52:43 +00:00
|
|
|
;; robe mode specific
|
2015-11-18 00:38:05 +00:00
|
|
|
"hd" 'robe-doc
|
|
|
|
"rsr" 'robe-rails-refresh
|
2015-10-15 20:52:43 +00:00
|
|
|
;; inf-enh-ruby-mode
|
2015-11-18 00:38:05 +00:00
|
|
|
"sf" 'ruby-send-definition
|
|
|
|
"sF" 'ruby-send-definition-and-go
|
|
|
|
"si" 'robe-start
|
|
|
|
"sr" 'ruby-send-region
|
|
|
|
"sR" 'ruby-send-region-and-go
|
|
|
|
"ss" 'ruby-switch-to-inf)))))
|
2014-12-08 21:04:34 +00:00
|
|
|
|
2015-11-10 23:42:33 +00:00
|
|
|
(defun ruby/init-rspec-mode ()
|
|
|
|
(use-package rspec-mode
|
2014-12-10 05:20:14 +00:00
|
|
|
:defer t
|
2016-06-07 02:52:19 +00:00
|
|
|
:init
|
|
|
|
(progn
|
2016-06-26 18:04:13 +00:00
|
|
|
(spacemacs/add-to-hooks 'spacemacs//ruby-enable-rspec-mode
|
|
|
|
'(ruby-mode-local-vars-hook
|
|
|
|
enh-ruby-mode-local-vars-hook))
|
2016-06-07 02:52:19 +00:00
|
|
|
;; remove hooks automatically added by rspec via autoload
|
|
|
|
;; because we want to be able to control when rspec-mode is
|
|
|
|
;; loaded based on the layer variable `ruby-test-runner'
|
|
|
|
(dolist (hook '(ruby-mode-hook enh-ruby-mode-hook))
|
|
|
|
(remove-hook hook 'rspec-enable-appropriate-mode)))
|
2015-03-09 03:12:28 +00:00
|
|
|
:config
|
|
|
|
(progn
|
2016-05-14 19:57:28 +00:00
|
|
|
(add-hook 'rspec-compilation-mode-hook 'spacemacs//inf-ruby-auto-enter)
|
2015-11-10 23:42:33 +00:00
|
|
|
(spacemacs|hide-lighter rspec-mode)
|
2015-10-15 20:52:43 +00:00
|
|
|
(dolist (mode '(ruby-mode enh-ruby-mode))
|
2015-11-27 04:55:43 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode
|
2016-02-07 11:41:32 +00:00
|
|
|
"ta" 'rspec-verify-all
|
|
|
|
"tb" 'rspec-verify
|
|
|
|
"tc" 'rspec-verify-continue
|
2016-03-03 21:34:09 +00:00
|
|
|
"td" 'ruby/rspec-verify-directory
|
2016-02-07 11:41:32 +00:00
|
|
|
"te" 'rspec-toggle-example-pendingness
|
|
|
|
"tf" 'rspec-verify-method
|
|
|
|
"tl" 'rspec-run-last-failed
|
|
|
|
"tm" 'rspec-verify-matching
|
|
|
|
"tr" 'rspec-rerun
|
|
|
|
"tt" 'rspec-verify-single
|
|
|
|
"t~" 'rspec-toggle-spec-and-target-find-example
|
|
|
|
"t TAB" 'rspec-toggle-spec-and-target)))))
|
2015-04-07 20:02:53 +00:00
|
|
|
|
2015-09-08 23:03:42 +00:00
|
|
|
(defun ruby/init-rubocop ()
|
|
|
|
(use-package rubocop
|
|
|
|
:defer t
|
2015-11-27 04:55:43 +00:00
|
|
|
:init (spacemacs/add-to-hooks 'rubocop-mode '(ruby-mode-hook
|
|
|
|
enh-ruby-mode-hook))
|
2016-06-07 02:24:47 +00:00
|
|
|
:config (dolist (mode '(ruby-mode enh-ruby-mode))
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "mrr" "ruby/RuboCop")
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode
|
|
|
|
"rrd" 'rubocop-check-directory
|
|
|
|
"rrD" 'rubocop-autocorrect-directory
|
|
|
|
"rrf" 'rubocop-check-current-file
|
|
|
|
"rrF" 'rubocop-autocorrect-current-file
|
|
|
|
"rrp" 'rubocop-check-project
|
|
|
|
"rrP" 'rubocop-autocorrect-project))))
|
2015-09-08 23:03:42 +00:00
|
|
|
|
2015-12-06 02:08:22 +00:00
|
|
|
(defun ruby/init-ruby-mode ()
|
|
|
|
(use-package ruby-mode
|
|
|
|
:defer t
|
2016-02-24 13:40:25 +00:00
|
|
|
:mode (("Appraisals\\'" . ruby-mode)
|
|
|
|
("Puppetfile" . ruby-mode))
|
2016-08-13 13:43:37 +00:00
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(spacemacs|define-jump-handlers ruby-mode)
|
|
|
|
(spacemacs/declare-prefix-for-mode 'ruby-mode "mt" "ruby/test"))
|
2016-06-07 02:24:47 +00:00
|
|
|
:config (spacemacs/set-leader-keys-for-major-mode 'ruby-mode
|
|
|
|
"'" 'ruby-toggle-string-quotes
|
|
|
|
"{" 'ruby-toggle-block)))
|
2015-12-06 02:08:22 +00:00
|
|
|
|
|
|
|
(defun ruby/init-ruby-tools ()
|
|
|
|
(use-package ruby-tools
|
|
|
|
:defer t
|
2016-06-07 02:24:47 +00:00
|
|
|
:init (dolist (hook '(ruby-mode-hook enh-ruby-mode-hook))
|
|
|
|
(add-hook hook 'ruby-tools-mode))
|
2015-12-06 02:08:22 +00:00
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
(spacemacs|hide-lighter ruby-tools-mode)
|
|
|
|
(dolist (mode '(ruby-mode enh-ruby-mode))
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "mx" "ruby/text")
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode
|
|
|
|
"x\'" 'ruby-tools-to-single-quote-string
|
|
|
|
"x\"" 'ruby-tools-to-double-quote-string
|
|
|
|
"x:" 'ruby-tools-to-symbol)))))
|
|
|
|
|
2015-11-10 23:42:33 +00:00
|
|
|
(defun ruby/init-ruby-test-mode ()
|
|
|
|
"Define keybindings for ruby test mode"
|
|
|
|
(use-package ruby-test-mode)
|
|
|
|
:defer t
|
2016-06-26 18:04:13 +00:00
|
|
|
:init (spacemacs/add-to-hooks 'spacemacs//ruby-enable-ruby-test-mode
|
|
|
|
'(ruby-mode-local-vars-hook
|
|
|
|
enh-ruby-mode-local-vars-hook))
|
2015-11-10 23:42:33 +00:00
|
|
|
:config
|
|
|
|
(progn
|
2016-06-07 02:52:19 +00:00
|
|
|
;; `ruby-test-mode' adds a hook to enable itself, this hack
|
|
|
|
;; removes it to be sure that we control the loading of the
|
|
|
|
;; mode
|
|
|
|
(remove-hook 'ruby-mode-hook 'ruby-test-enable)
|
2015-11-10 23:42:33 +00:00
|
|
|
(spacemacs|hide-lighter ruby-test-mode)
|
|
|
|
(dolist (mode '(ruby-mode enh-ruby-mode))
|
2015-11-27 05:25:55 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode
|
|
|
|
"tb" 'ruby-test-run
|
|
|
|
"tt" 'ruby-test-run-at-point))))
|
2015-11-10 23:42:33 +00:00
|
|
|
|
2015-12-06 02:01:03 +00:00
|
|
|
(defun ruby/init-rvm ()
|
|
|
|
(use-package rvm
|
2016-01-03 14:12:56 +00:00
|
|
|
:if (equal ruby-version-manager 'rvm)
|
2015-12-06 02:01:03 +00:00
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(setq rspec-use-rvm t)
|
|
|
|
(spacemacs/add-to-hooks 'rvm-activate-corresponding-ruby
|
|
|
|
'(ruby-mode-hook enh-ruby-mode-hook)))))
|
2015-12-11 06:55:37 +00:00
|
|
|
|
|
|
|
(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 ""))))
|
2016-02-29 19:24:52 +00:00
|
|
|
|
|
|
|
(defun ruby/init-rake ()
|
|
|
|
(use-package rake
|
|
|
|
:defer t
|
2016-03-05 19:54:17 +00:00
|
|
|
:init (setq rake-cache-file (concat spacemacs-cache-directory "rake.cache"))
|
2016-06-07 02:24:47 +00:00
|
|
|
:config (dolist (mode '(ruby-mode enh-ruby-mode))
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode
|
|
|
|
"kk" 'rake
|
|
|
|
"kr" 'rake-rerun
|
|
|
|
"kR" 'rake-regenerate-cache
|
|
|
|
"kf" 'rake-find-task))))
|