2015-07-04 03:33:13 +00:00
|
|
|
;;; packages.el --- Ruby Layer packages File for Spacemacs
|
|
|
|
;;
|
2021-03-22 20:11:29 +00:00
|
|
|
;; Copyright (c) 2012-2021 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.
|
|
|
|
;;
|
2021-03-24 03:31:44 +00:00
|
|
|
;; This program is free software; you can redistribute it and/or modify
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
|
|
|
;;
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
;;
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2015-07-04 03:33:13 +00:00
|
|
|
|
2019-12-21 22:41:04 +00:00
|
|
|
(defconst ruby-packages
|
|
|
|
'(
|
2021-01-09 07:34:04 +00:00
|
|
|
add-node-modules-path
|
2019-12-21 22:41:04 +00:00
|
|
|
bundler
|
|
|
|
chruby
|
|
|
|
company
|
|
|
|
counsel-gtags
|
|
|
|
dap-mode
|
|
|
|
(enh-ruby-mode :toggle ruby-enable-enh-ruby-mode)
|
|
|
|
evil-matchit
|
|
|
|
flycheck
|
|
|
|
ggtags
|
|
|
|
helm-gtags
|
|
|
|
minitest
|
|
|
|
org
|
|
|
|
popwin
|
2021-01-09 07:34:04 +00:00
|
|
|
prettier-js
|
2019-12-21 22:41:04 +00:00
|
|
|
rake
|
|
|
|
rbenv
|
|
|
|
robe
|
|
|
|
rspec-mode
|
|
|
|
rubocop
|
|
|
|
rubocopfmt
|
|
|
|
ruby-hash-syntax
|
|
|
|
(ruby-mode :location built-in :toggle (not ruby-enable-enh-ruby-mode))
|
|
|
|
ruby-refactor
|
|
|
|
ruby-test-mode
|
|
|
|
ruby-tools
|
|
|
|
rvm
|
|
|
|
seeing-is-believing
|
2020-05-16 21:32:30 +00:00
|
|
|
smartparens))
|
2015-10-19 04:10:32 +00:00
|
|
|
|
2015-12-06 02:08:22 +00:00
|
|
|
(defun ruby/init-bundler ()
|
|
|
|
(use-package bundler
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2016-06-07 02:24:47 +00:00
|
|
|
:init (dolist (mode '(ruby-mode enh-ruby-mode))
|
2019-12-17 15:30:44 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode mode "mb"
|
2021-03-18 04:57:44 +00:00
|
|
|
(if (eq ruby-backend 'lsp) "build/bundle" "bundle"))
|
2016-06-07 02:24:47 +00:00
|
|
|
(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
|
|
|
|
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
|
2018-03-04 04:37:53 +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
|
|
|
|
2021-01-09 07:34:04 +00:00
|
|
|
(defun ruby/post-init-add-node-modules-path ()
|
|
|
|
(spacemacs/add-to-hooks #'add-node-modules-path '(ruby-mode-hook)))
|
|
|
|
|
2019-09-30 01:30:53 +00:00
|
|
|
(defun ruby/post-init-company ()
|
|
|
|
(add-hook 'ruby-mode-local-vars-hook #'spacemacs//ruby-setup-company))
|
|
|
|
|
|
|
|
(defun ruby/post-init-counsel-gtags ()
|
2019-12-17 15:30:44 +00:00
|
|
|
(spacemacs/counsel-gtags-define-keys-for-mode 'ruby-mode)
|
|
|
|
(spacemacs/counsel-gtags-define-keys-for-mode 'enh-ruby-mode))
|
2019-09-30 01:30:53 +00:00
|
|
|
|
|
|
|
(defun ruby/pre-init-dap-mode ()
|
2021-03-18 04:57:44 +00:00
|
|
|
(when (eq ruby-backend 'lsp)
|
|
|
|
(add-to-list 'spacemacs--dap-supported-modes 'ruby-mode)
|
|
|
|
(add-to-list 'spacemacs--dap-supported-modes 'enh-ruby-mode))
|
2019-12-17 15:30:44 +00:00
|
|
|
(spacemacs/add-to-hooks #'spacemacs//ruby-setup-dap
|
|
|
|
'(ruby-mode-local-vars-hook
|
|
|
|
enh-ruby-mode-local-vars-hook)))
|
2019-09-30 01:30:53 +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)
|
2020-07-14 17:09:31 +00:00
|
|
|
("\\.\\(rb\\|rabl\\|ru\\|builder\\|rake\\|thor\\|gemspec\\|jbuilder\\|pryrc\\)\\'" . enh-ruby-mode))
|
2015-07-03 16:38:52 +00:00
|
|
|
:interpreter "ruby"
|
2016-08-13 13:43:37 +00:00
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(setq enh-ruby-deep-indent-paren nil
|
2018-09-02 13:50:11 +00:00
|
|
|
enh-ruby-hanging-paren-deep-indent-level 2)
|
2020-07-14 17:42:20 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode 'enh-ruby-mode "mi" "insert")
|
2018-09-02 13:50:11 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode 'enh-ruby-mode "mt" "test")
|
2019-04-18 18:16:01 +00:00
|
|
|
|
2019-12-17 15:30:44 +00:00
|
|
|
(add-hook 'enh-ruby-mode-hook #'spacemacs//ruby-setup-backend)
|
|
|
|
(add-hook 'enh-ruby-mode-local-vars-hook
|
|
|
|
#'spacemacs/ruby-maybe-highlight-debugger-keywords))
|
2018-09-02 13:50:11 +00:00
|
|
|
:config
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'enh-ruby-mode
|
2020-07-14 17:32:02 +00:00
|
|
|
"if" 'spacemacs/ruby-insert-frozen-string-literal-comment
|
|
|
|
"is" 'spacemacs/ruby-insert-shebang
|
2020-07-14 17:19:21 +00:00
|
|
|
"r{" 'enh-ruby-toggle-block
|
|
|
|
"r}" 'enh-ruby-toggle-block)))
|
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 ()
|
2017-02-14 03:27:29 +00:00
|
|
|
(spacemacs/enable-flycheck 'ruby-mode)
|
|
|
|
(spacemacs/enable-flycheck 'enh-ruby-mode))
|
2015-02-10 23:08:15 +00:00
|
|
|
|
2016-04-05 04:08:34 +00:00
|
|
|
(defun ruby/post-init-ggtags ()
|
2018-01-21 22:38:30 +00:00
|
|
|
(spacemacs/add-to-hooks 'spacemacs/ggtags-mode-enable
|
|
|
|
'(ruby-mode-local-vars-hook
|
|
|
|
enh-ruby-mode-local-vars-hook)))
|
2016-04-05 04:08:34 +00:00
|
|
|
|
|
|
|
(defun ruby/post-init-helm-gtags ()
|
2018-01-21 22:38:30 +00:00
|
|
|
(dolist (mode '(ruby-mode enh-ruby-mode))
|
|
|
|
(spacemacs/helm-gtags-define-keys-for-mode mode)))
|
2016-04-05 04:08:34 +00:00
|
|
|
|
2016-09-07 21:33:54 +00:00
|
|
|
(defun ruby/init-minitest ()
|
|
|
|
(use-package minitest
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2016-09-07 21:33:54 +00:00
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(spacemacs/add-to-hooks 'spacemacs//ruby-enable-minitest-mode
|
|
|
|
'(ruby-mode-local-vars-hook
|
|
|
|
enh-ruby-mode-local-vars-hook))
|
|
|
|
;; remove hooks added by minitest mode
|
|
|
|
(dolist (hook '(ruby-mode-hook enh-ruby-mode-hook))
|
|
|
|
(remove-hook hook 'minitest-enable-appropriate-mode)))
|
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
(spacemacs|hide-lighter minitest-mode)
|
|
|
|
(dolist (mode '(ruby-mode enh-ruby-mode))
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode
|
|
|
|
"ta" 'minitest-verify-all
|
|
|
|
"tb" 'minitest-verify
|
|
|
|
"tr" 'minitest-rerun
|
|
|
|
"ts" 'minitest-verify-single)))))
|
|
|
|
|
2017-04-26 11:42:13 +00:00
|
|
|
(defun ruby/pre-init-org ()
|
|
|
|
(spacemacs|use-package-add-hook org
|
|
|
|
:post-config (add-to-list 'org-babel-load-languages '(ruby . t))))
|
|
|
|
|
2021-01-09 07:34:04 +00:00
|
|
|
(defun ruby/pre-init-prettier-js ()
|
|
|
|
(add-to-list 'spacemacs--prettier-modes 'ruby-mode)
|
|
|
|
(add-to-list 'spacemacs--prettier-modes 'enh-ruby-mode))
|
|
|
|
|
2020-07-03 19:44:51 +00:00
|
|
|
(defun ruby/pre-init-popwin ()
|
|
|
|
(spacemacs|use-package-add-hook popwin
|
|
|
|
:post-config
|
|
|
|
(push '("*Bundler*" :dedicated t :position bottom :stick t :noselect t :height 0.4)
|
|
|
|
popwin:special-display-config)
|
|
|
|
(push '("*projectile-rails-compilation*" :dedicated t :position bottom :stick t :noselect t :height 0.4)
|
|
|
|
popwin:special-display-config)
|
|
|
|
(push '("*projectile-rails-generate*" :dedicated t :position bottom :stick t :noselect t :height 0.4)
|
|
|
|
popwin:special-display-config)
|
|
|
|
(push '("*rake-compilation*" :dedicated t :position bottom :stick t :noselect t :height 0.4)
|
|
|
|
popwin:special-display-config)
|
|
|
|
(push '("*rspec-compilation*" :dedicated t :position bottom :stick t :noselect t :height 0.4)
|
|
|
|
popwin:special-display-config)
|
|
|
|
(push '("^\\*RuboCop.+\\*$" :regexp t :dedicated t :position bottom :stick t :noselect t :height 0.4)
|
|
|
|
popwin:special-display-config)))
|
2016-01-23 16:08:18 +00:00
|
|
|
|
2019-09-30 01:30:53 +00:00
|
|
|
(defun ruby/init-rake ()
|
|
|
|
(use-package rake
|
|
|
|
:defer t
|
|
|
|
:init (setq rake-cache-file (concat spacemacs-cache-directory "rake.cache"))
|
|
|
|
:config (dolist (mode '(ruby-mode enh-ruby-mode))
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "mk" "rake")
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode
|
|
|
|
"kk" 'rake
|
|
|
|
"kr" 'rake-rerun
|
|
|
|
"kR" 'rake-regenerate-cache
|
|
|
|
"kf" 'rake-find-task))))
|
|
|
|
|
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)
|
2019-04-18 18:16:01 +00:00
|
|
|
:defer t))
|
2014-12-23 03:51:44 +00:00
|
|
|
|
2014-12-08 21:04:34 +00:00
|
|
|
(defun ruby/init-robe ()
|
|
|
|
(use-package robe
|
2019-04-18 18:16:01 +00:00
|
|
|
:if (eq ruby-backend 'robe)
|
2018-03-04 04:37:53 +00:00
|
|
|
: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-08-13 13:43:37 +00:00
|
|
|
(spacemacs/add-to-hooks 'robe-jump
|
2019-12-21 22:41:04 +00:00
|
|
|
'(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))
|
2018-09-02 13:50:11 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode mode "mg" "goto")
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "mh" "docs")
|
2019-12-17 15:30:44 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode mode "mr" "refactor/robe")
|
2018-09-02 13:50:11 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode mode "mrs" "robe")
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "ms" "repl")
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode
|
2018-07-09 20:48:05 +00:00
|
|
|
"'" 'robe-start
|
2015-10-15 20:52:43 +00:00
|
|
|
;; robe mode specific
|
2017-07-03 16:04:44 +00:00
|
|
|
"hh" 'robe-doc
|
2015-11-18 00:38:05 +00:00
|
|
|
"rsr" 'robe-rails-refresh
|
2015-10-15 20:52:43 +00:00
|
|
|
;; inf-enh-ruby-mode
|
2018-02-09 11:30:50 +00:00
|
|
|
"sb" 'ruby-send-buffer
|
2018-05-28 14:13:54 +00:00
|
|
|
"sB" 'ruby-send-buffer-and-go
|
2015-11-18 00:38:05 +00:00
|
|
|
"sf" 'ruby-send-definition
|
|
|
|
"sF" 'ruby-send-definition-and-go
|
|
|
|
"si" 'robe-start
|
2018-05-19 08:37:05 +00:00
|
|
|
"sl" 'ruby-send-line
|
2018-05-28 14:13:54 +00:00
|
|
|
"sL" 'ruby-send-line-and-go
|
2015-11-18 00:38:05 +00:00
|
|
|
"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
|
2018-03-04 04:37:53 +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
|
2018-03-04 04:37:53 +00:00
|
|
|
: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))
|
2019-04-18 18:16:01 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode mode "mR" "RuboCop")
|
2016-06-07 02:24:47 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode
|
2019-04-18 18:16:01 +00:00
|
|
|
"Rd" 'rubocop-check-directory
|
|
|
|
"RD" 'rubocop-autocorrect-directory
|
|
|
|
"Rf" 'rubocop-check-current-file
|
|
|
|
"Rp" 'rubocop-check-project
|
|
|
|
"RP" 'rubocop-autocorrect-project))))
|
2015-09-08 23:03:42 +00:00
|
|
|
|
2019-05-10 14:24:39 +00:00
|
|
|
(defun ruby/init-rubocopfmt ()
|
|
|
|
(use-package rubocopfmt
|
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(setq-default rubocopfmt-disabled-cops '())
|
|
|
|
|
|
|
|
(dolist (mode '(ruby-mode enh-ruby-mode))
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "m=" "format")
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode
|
|
|
|
"=r" #'rubocopfmt)))))
|
|
|
|
|
2019-09-30 01:30:53 +00:00
|
|
|
(defun ruby/init-ruby-hash-syntax ()
|
|
|
|
(use-package ruby-hash-syntax
|
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(dolist (mode '(ruby-mode enh-ruby-mode))
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode
|
|
|
|
"xh" 'ruby-hash-syntax-toggle))))
|
|
|
|
|
2015-12-06 02:08:22 +00:00
|
|
|
(defun ruby/init-ruby-mode ()
|
|
|
|
(use-package ruby-mode
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2016-02-24 13:40:25 +00:00
|
|
|
:mode (("Appraisals\\'" . ruby-mode)
|
2021-03-18 04:57:44 +00:00
|
|
|
("\\(Rake\\|Thor\\|Guard\\|Gem\\|Cap\\|Vagrant\\|Berks\\|Pod\\|Puppet\\)file\\'" . ruby-mode)
|
|
|
|
("\\.\\(rb\\|rabl\\|ru\\|builder\\|rake\\|thor\\|gemspec\\|jbuilder\\|pryrc\\)\\'" . ruby-mode))
|
2016-08-13 13:43:37 +00:00
|
|
|
:init
|
|
|
|
(progn
|
2020-07-14 17:32:02 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode 'ruby-mode "mi" "insert")
|
2018-09-02 13:50:11 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode 'ruby-mode "mt" "test")
|
|
|
|
(spacemacs/declare-prefix-for-mode 'ruby-mode "mT" "toggle")
|
2019-04-18 18:16:01 +00:00
|
|
|
|
|
|
|
;; setup version manager which is necessary to find gems in path for backend
|
|
|
|
(spacemacs//ruby-setup-version-manager)
|
2019-12-17 15:30:44 +00:00
|
|
|
(add-hook 'ruby-mode-hook #'spacemacs//ruby-setup-backend)
|
|
|
|
(add-hook 'ruby-mode-local-vars-hook
|
|
|
|
#'spacemacs/ruby-maybe-highlight-debugger-keywords))
|
2020-07-14 17:32:02 +00:00
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
;; This might have been important 10 years ago but now it's frustrating.
|
|
|
|
(setq ruby-insert-encoding-magic-comment nil)
|
|
|
|
|
2021-01-09 07:34:04 +00:00
|
|
|
(when ruby-prettier-on-save
|
|
|
|
(add-hook 'ruby-mode-hook 'spacemacs/ruby-fmt-before-save-hook))
|
2020-07-14 17:32:02 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'ruby-mode
|
|
|
|
"if" 'spacemacs/ruby-insert-frozen-string-literal-comment
|
|
|
|
"is" 'spacemacs/ruby-insert-shebang
|
|
|
|
"r'" 'ruby-toggle-string-quotes
|
|
|
|
"r\"" 'ruby-toggle-string-quotes
|
|
|
|
"r{" 'ruby-toggle-block
|
|
|
|
"r}" 'ruby-toggle-block))))
|
2015-12-06 02:08:22 +00:00
|
|
|
|
2016-06-12 14:36:27 +00:00
|
|
|
(defun ruby/init-ruby-refactor ()
|
|
|
|
(use-package ruby-refactor
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2016-06-12 14:36:27 +00:00
|
|
|
:init (dolist (hook '(ruby-mode-hook enh-ruby-mode-hook))
|
|
|
|
(add-hook hook 'ruby-refactor-mode-launch))
|
|
|
|
:config
|
2019-12-17 15:30:44 +00:00
|
|
|
(dolist (mode '(ruby-mode enh-ruby-mode))
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "mre" "extract")
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode
|
|
|
|
"rem" 'ruby-refactor-extract-to-method
|
|
|
|
"rev" 'ruby-refactor-extract-local-variable
|
|
|
|
"rec" 'ruby-refactor-extract-constant
|
|
|
|
"rel" 'ruby-refactor-extract-to-let))))
|
2016-06-12 14:36:27 +00:00
|
|
|
|
2015-11-10 23:42:33 +00:00
|
|
|
(defun ruby/init-ruby-test-mode ()
|
|
|
|
"Define keybindings for ruby test mode"
|
2019-06-12 03:26:17 +00:00
|
|
|
(use-package ruby-test-mode
|
2018-03-04 04:37:53 +00:00
|
|
|
: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
|
2019-06-12 03:26:17 +00:00
|
|
|
"tt" 'ruby-test-run-at-point)))))
|
2015-11-10 23:42:33 +00:00
|
|
|
|
2019-09-30 01:30:53 +00:00
|
|
|
(defun ruby/init-ruby-tools ()
|
|
|
|
(use-package ruby-tools
|
|
|
|
:defer t
|
|
|
|
:init (dolist (hook '(ruby-mode-hook enh-ruby-mode-hook))
|
|
|
|
(add-hook hook 'ruby-tools-mode))
|
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
(spacemacs|hide-lighter ruby-tools-mode)
|
|
|
|
(dolist (mode '(ruby-mode enh-ruby-mode))
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "mx" "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-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)
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2015-12-06 02:01:03 +00:00
|
|
|
: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
|
|
|
|
2015-10-17 07:45:03 +00:00
|
|
|
(defun ruby/init-seeing-is-believing ()
|
|
|
|
(use-package seeing-is-believing
|
|
|
|
:defer t
|
|
|
|
:commands (seeing-is-believing seeing-is-believing-run seeing-is-believing-clear)
|
|
|
|
:if (executable-find "seeing_is_believing")
|
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(spacemacs|diminish seeing-is-believing " 👁" " @")
|
|
|
|
(dolist (hook '(ruby-mode-hook enh-ruby-mode-hook))
|
|
|
|
(add-hook hook 'seeing-is-believing))
|
|
|
|
(dolist (mode '(ruby-mode enh-ruby-mode))
|
2019-12-17 15:30:44 +00:00
|
|
|
(spacemacs/declare-prefix-for-mode mode "m@" "seeing-is-believing")
|
2015-10-17 07:45:03 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode
|
|
|
|
"@@" 'seeing-is-believing-run
|
|
|
|
"@c" 'seeing-is-believing-clear)))))
|
2019-09-30 01:30:53 +00:00
|
|
|
|
|
|
|
(defun ruby/pre-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 ""))))
|