Files
.emacs.d/modules/siren-ruby.el
Jim Myhrberg c791150a06 Add rewritten config, dubbed emacs-siren
I've taken a lot of inspiration from Emacs-Prelude when it came to the
structure of this rewritten config. I didn't want to use Prelude as I
don't agree with all it's defaults, nor do I want to have to deal with
any future changes in Prelude that might break things for me. So instead
I went down the fully custom path, but heavily inspired by Prelude, both
in terms of file/code structure, and also some of it's features.

Compared to my old config setup, it's got most of the same things, but
nearly everything is in a module file now, making it easy to fully
enable/disable certain features.
2015-10-04 08:56:07 +01:00

84 lines
3.2 KiB
EmacsLisp

;;
;; ruby
;;
(require 'siren-programming)
(siren-require-packages '(ruby-tools inf-ruby yari company-inf-ruby))
;; Force-load custom vendored ruby-mode fetched from:
;; - https://raw.github.com/ruby/ruby/trunk/misc/ruby-mode.el
(load (expand-file-name "ruby-mode.el" siren-vendor-dir))
;; Rake files are ruby, too, as are gemspecs, rackup files, and gemfiles.
(add-to-list 'auto-mode-alist '("\\.rake\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("Rakefile\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.gemspec\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.ru\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("Gemfile\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("Guardfile\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("Capfile\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.cap\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.thor\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.rabl\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("Thorfile\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("Vagrantfile\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.jbuilder\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("Podfile\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.podspec\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("Puppetfile\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("Berksfile\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("Appraisals\\'" . ruby-mode))
;; We never want to edit Rubinius bytecode
(add-to-list 'completion-ignored-extensions ".rbc")
(define-key 'help-command (kbd "R") 'yari)
;; Set up hs-mode (HideShow) for Ruby
(add-to-list 'hs-special-modes-alist
`(ruby-mode
,(rx (or "def" "class" "module" "do")) ;; Block start
,(rx (or "end")) ;; Block end
,(rx (or "#" "=begin")) ;; Comment start
ruby-forward-sexp nil))
(eval-after-load 'company
'(add-to-list 'company-backends 'company-inf-ruby))
(eval-after-load 'ruby-mode
'(progn
(defun siren-ruby-mode-defaults ()
(siren-prog-mode-defaults)
(inf-ruby-minor-mode +1)
(ruby-tools-mode +1)
(setq tab-width 2)
(hs-minor-mode 1)
(company-mode +1)
(subword-mode +1)
(highlight-indentation-mode)
(highlight-indentation-current-column-mode)
(setq ruby-deep-arglist nil)
(setq ruby-deep-indent-paren nil)
(setq c-tab-always-indent nil)
(setq ruby-use-encoding-map nil)
(define-key ruby-mode-map (kbd "C-j") 'newline-and-indent)
(define-key ruby-mode-map (kbd "RET") 'newline-and-indent)
(define-key ruby-mode-map (kbd "C-c C-h") 'toggle-hiding)
(define-key ruby-mode-map (kbd "C-c C-l") 'goto-line))
(setq siren-ruby-mode-hook 'siren-ruby-mode-defaults)
(add-hook 'ruby-mode-hook (lambda ()
(run-hooks 'siren-ruby-mode-hook)))))
;; ;; Auto-complete when indenting
;; (defadvice ruby-indent-command (around ac-before-ruby-indent activate)
;; "Call `auto-complete' if text was recently entered"
;; (if (ac-trigger-command-p last-command)
;; (auto-complete)
;; ad-do-it))
(provide 'siren-ruby)