Add finally working company
This commit is contained in:
parent
c59eb1ceb8
commit
a9cf902017
7 changed files with 105 additions and 54 deletions
|
|
@ -5,11 +5,16 @@
|
|||
(require 'company)
|
||||
(require 'ruby-mode)
|
||||
(require 'robe)
|
||||
(require 'rvm)
|
||||
(require 'rspec-mode)
|
||||
(defun ruby-mode-config ()
|
||||
|
||||
;;========== Editor config =========================
|
||||
(defun editor-ruby-mode-config ()
|
||||
"Setup editor for Ruby."
|
||||
|
||||
;; Indentation and line length
|
||||
(set-width-80)
|
||||
(set-indent 2)
|
||||
|
||||
;; Do not align 'begin' and 'while' ;;
|
||||
(setq ruby-align-to-stmt-keywords '(if begin case elseif rescue))
|
||||
|
||||
|
|
@ -19,26 +24,36 @@
|
|||
;; Do not insert encoding comments
|
||||
(setq ruby-insert-encoding-magic-comment nil)
|
||||
|
||||
;; Use robe
|
||||
(add-hook 'ruby-mode-hook 'robe-mode)
|
||||
(defadvice inf-ruby-console-auto (before activate-rvm-for-robe activate)
|
||||
"Activate proper RVM on activation of Robe."
|
||||
(rvm-activate-corresponding-ruby))
|
||||
|
||||
;; Setup autocomplete for robe
|
||||
(eval-after-load 'company
|
||||
'(push 'company-robe company-backends))
|
||||
(add-hook 'robe-mode-hook 'ac-robe-setup)
|
||||
|
||||
;; User rspec-mode
|
||||
(add-hook 'ruby-mode-hook 'rspec-mode)
|
||||
(eval-after-load 'rspec-mode '(rspec-install-snippets))
|
||||
|
||||
;; Use web-mode for erb
|
||||
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode)))
|
||||
|
||||
(add-hook 'ruby-mode-hook 'ruby-mode-config)
|
||||
(add-hook 'ruby-mode-hook 'set-width-80)
|
||||
;;========== Rspec config =========================
|
||||
(defun rspec-ruby-mode-config ()
|
||||
"Use rspec-mode."
|
||||
(rspec-mode t)
|
||||
(eval-after-load 'rspec-mode '(rspec-install-snippets)))
|
||||
|
||||
;;========== Robe config ==========================
|
||||
(defun robe-ruby-mode-config ()
|
||||
"Use robe."
|
||||
;; Activate modes
|
||||
(robe-mode 1)
|
||||
(company-mode 1)
|
||||
(rspec-mode 1)
|
||||
|
||||
;; Activate RVM
|
||||
(rvm-activate-corresponding-ruby)
|
||||
|
||||
;; Initalize completion
|
||||
(set (make-local-variable 'company-backends)
|
||||
'((company-robe company-capf company-dabbrev-code company-yasnippet
|
||||
company-files)))
|
||||
(ac-robe-setup))
|
||||
|
||||
;;========== Hooks ================================
|
||||
(add-hook 'ruby-mode-hook 'editor-ruby-mode-config)
|
||||
(add-hook 'ruby-mode-hook 'robe-ruby-mode-config)
|
||||
(add-hook 'ruby-mode-hook 'rspec-ruby-mode-config)
|
||||
|
||||
;; Use longer lines for HAML
|
||||
(add-hook 'haml-mode-hook 'set-width-120)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue