This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
spacemacs/layers/+lang/ruby/packages.el

135 lines
4.7 KiB
EmacsLisp
Raw Normal View History

;;; 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
(setq ruby-packages
2014-12-08 21:04:34 +00:00
'(
bundler
2015-04-18 00:40:39 +00:00
company
2015-02-21 03:47:12 +00:00
enh-ruby-mode
evil-matchit
flycheck
2014-12-08 21:04:34 +00:00
robe
ruby-test-mode
2015-08-10 12:45:21 +00:00
ruby-tools))
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))
2014-12-08 21:04:34 +00:00
(defun ruby/init-rbenv ()
"Initialize RBENV mode"
(use-package rbenv
:defer t
: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 ()
"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)
("\\.\\(rb\\|rabl\\|ru\\|builder\\|rake\\|thor\\|gemspec\\|jbuilder\\)\\'" . enh-ruby-mode))
:interpreter "ruby"
: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
(defun ruby/post-init-evil-matchit ()
(use-package evil-matchit-ruby
:defer t
:init (add-hook `enh-ruby-mode `turn-on-evil-matchit-mode)
:config
(progn
(plist-put evilmi-plugins 'enh-ruby-mode '((evilmi-simple-get-tag evilmi-simple-jump)
(evilmi-ruby-get-tag evilmi-ruby-jump))))))
(defun ruby/post-init-flycheck ()
2015-02-21 03:47:12 +00:00
(add-hook 'enh-ruby-mode-hook 'flycheck-mode))
(defun ruby/init-ruby-tools ()
(use-package ruby-tools
:defer t
:init
(add-hook 'enh-ruby-mode-hook 'ruby-tools-mode)
:config
(progn
(spacemacs|hide-lighter ruby-tools-mode)
(evil-leader/set-key-for-mode 'enh-ruby-mode "mx\'" 'ruby-tools-to-single-quote-string)
(evil-leader/set-key-for-mode 'enh-ruby-mode "mx\"" 'ruby-tools-to-double-quote-string)
(evil-leader/set-key-for-mode 'enh-ruby-mode "mx:" 'ruby-tools-to-symbol))))
(defun ruby/init-bundler ()
(use-package bundler
:defer t
: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-08 21:04:34 +00:00
(defun ruby/init-robe ()
"Initialize Robe mode"
(use-package robe
:defer t
: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)))
:config
(progn
2015-03-21 22:41:31 +00:00
(spacemacs|hide-lighter robe-mode)
;; 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-ruby-test-mode ()
"Define keybindings for ruby test mode"
(use-package ruby-test-mode
: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))))
(when (configuration-layer/layer-usedp 'auto-completion)
(defun ruby/post-init-company ()
(spacemacs|add-company-hook enh-ruby-mode)
(eval-after-load 'company-dabbrev-code
'(push 'enh-ruby-mode company-dabbrev-code-modes))))