forked from lest/emacs-config
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrc-ruby.el
81 lines (70 loc) · 3.28 KB
/
rc-ruby.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
(eval-after-load 'ruby-mode
'(progn
(define-key ruby-mode-map (kbd "RET") 'reindent-then-newline-and-indent)))
(add-to-list 'auto-mode-alist '("\\.rake$" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.gemspec$" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.rjs$" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.ru$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Rakefile$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Gemfile$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Capfile$" . ruby-mode))
(add-to-list 'auto-mode-alist '("/\\.\\(irb\\|cap\\)rc$" . ruby-mode))
;; flymake
(eval-after-load 'ruby-mode
'(progn
(require 'flymake)
;; Invoke ruby with '-c' to get syntax checking
(defun flymake-ruby-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "ruby" (list "-c" local-file))))
(push '("\\.rb$" flymake-ruby-init) flymake-allowed-file-name-masks)
(push '("\\.rake$" flymake-ruby-init) flymake-allowed-file-name-masks)
(push '("\\.gemspec$" flymake-ruby-init) flymake-allowed-file-name-masks)
(push '("\\.ru$" flymake-ruby-init) flymake-allowed-file-name-masks)
(push '("Rakefile$" flymake-ruby-init) flymake-allowed-file-name-masks)
(push '("Gemfile$" flymake-ruby-init) flymake-allowed-file-name-masks)
(push '("Capfile$" flymake-ruby-init) flymake-allowed-file-name-masks)
(push '("^\\(.*\\):\\([0-9]+\\): \\(.*\\)$" 1 2 nil 3)
flymake-err-line-patterns)
(add-hook 'ruby-mode-hook
(lambda ()
(when (and buffer-file-name
(file-writable-p
(file-name-directory buffer-file-name))
(file-writable-p buffer-file-name)
(if (fboundp 'tramp-list-remote-buffers)
(not (subsetp
(list (current-buffer))
(tramp-list-remote-buffers)))
t))
(local-set-key (kbd "C-c d")
'flymake-display-err-menu-for-current-line)
(flymake-mode t))))))
;; rinary
(add-to-list 'load-path (concat config-dir "vendor/rinari"))
(require 'rinari)
;; yasnippets-rails
;;(load (concat config-dir "vendor/yasnippets-rails/setup.el"))
;; rspec
(add-to-list 'load-path (concat config-dir "vendor/rspec-mode"))
(require 'rspec-mode)
;; cucumber
(add-to-list 'load-path (concat config-dir "vendor/cucumber.el"))
(require 'feature-mode)
;; rhtml
(add-to-list 'load-path (concat config-dir "vendor/rhtml"))
(autoload 'rhtml-mode "rhtml-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.rhtml$" . rhtml-mode))
(add-to-list 'auto-mode-alist '("\\.html\\.erb$" . rhtml-mode))
;; cocoapods support
(add-to-list 'auto-mode-alist '("\\.podspec$" . ruby-mode))
;; disable flymake errors highlighting before save
(setq flymake-no-changes-timeout most-positive-fixnum)
(setq flymake-start-syntax-check-on-newline nil)
;; rvm
(add-to-list 'load-path (concat config-dir "vendor/rvm.el"))
(require 'rvm)