RT,最近在学习ruby,感觉robe的补全没有rubymine的补全那么细致。比如定义一个类,写了class XXX回车之后需要定义实例变量,此时写attr_accessor就不会补全;还有自定义类的实例使用的时候也不会补全自定义的方法。有没有哪位前辈能给我点建议?
贴下我ruby-mode的配置,参考了purcell的配置,请大家帮我看下,谢谢:pray:。
;;init-ruby.el
(require-package 'ruby-mode)
(require-package 'ruby-hash-syntax)
(require-package 'robe)
(require-package 'inf-ruby)
(require-package 'company-inf-ruby)
(require-package 'ruby-electric)
(require-package 'flymake-ruby)
(require-package 'ruby-hash-syntax)
(require-package 'goto-gem)
;; ruby files
(add-auto-mode 'ruby-mode
"Rakefile\\'" "\\.rake\\'" "\\.rxml\\'"
"\\.rjs\\'" "\\.irbrc\\'" "\\.pryrc\\'" "\\.builder\\'" "\\.ru\\'"
"\\.gemspec\\'" "Gemfile\\'" "Kirkfile\\'")
(after-load 'ruby-mode
(define-key ruby-mode-map (kbd "TAB") 'indent-for-tab-command)
(add-hook 'ruby-mode-hook
(lambda ()
(unless (derived-mode-p 'prog-mode)
(run-hooks 'prog-mode-hook)))))
(add-hook 'ruby-mode-hook 'subword-mode)
(after-load 'page-break-lines
(push 'ruby-mode page-break-lines-modes))
(defun xuyou/suppress-ruby-mode-keyword-highlights ()
"Suppress highlight-symbol for do/end etc."
(set (make-local-variable 'highlight-symbol-ignore-list)
(list (concat "\\_<" (regexp-opt '("do" "end")) "\\_>"))))
(add-hook 'ruby-mode-hook 'xuyou/suppress-ruby-mode-keyword-highlights)
(after-load 'company
(dolist (hook '(ruby-mode-hook inf-ruby-mode-hook))
(add-hook hook
(lambda () (local-push-company-backend 'company-robe)))))
(after-load 'page-break-lines
(push 'ruby-mode page-break-lines-modes))
(eval-after-load 'company
'(add-to-list 'company-backends 'company-inf-ruby))
(eval-after-load 'company
'(push 'company-robe company-backends))
(add-hook 'compilation-filter-hook 'inf-ruby-auto-enter)
;; ruby-compilation
(require-package 'ruby-compilation)
(after-load 'ruby-mode
(let ((m ruby-mode-map))
(define-key m (kbd "C-c h r") 'ruby-compilation-run)
(define-key m [f5] 'ruby-compilation-this-buffer)))
(after-load 'ruby-compilation
(defalias 'rake 'ruby-compilation-rake))
;; ri reading
(require-package 'yari)
(defalias 'ri 'yari)
;; for rails
;;(require-package 'rinari)
;;(after-load 'rinari
;; (diminish 'rinari-minor-mode "Rin"))
;;(global-rinari-mode)
;;(defun update-rails-ctags ()
;; (interactive)
;; (let ((default-directory (or (rinari-root) default-directory)))
;; (shell-command (concat "ctags -a -e -f " rinari-tags-file-name " --tag-relative -R app lib vendor test"))))
;; add hooks
(add-hook 'ruby-mode-hook 'flymake-ruby-load)
(add-hook 'ruby-mode-hook 'subword-mode)
(add-hook 'ruby-mode-hook (lambda () (ruby-electric-mode t)))
(add-hook 'ruby-mode-hook 'inf-ruby-minor-mode)
(add-hook 'ruby-mode-hook 'robe-mode)
(add-hook 'ruby-mode-hook 'yard-mode)
(add-hook 'ruby-mode-hook
(lambda () (highlight-indentation-current-column-mode)))
(provide 'init-ruby)