Move ruby and python configuration to their specific files

This commit is contained in:
Maciej Szlosarczyk 2017-08-28 17:01:51 +03:00
parent df6c4fb449
commit 2c025fb09f
No known key found for this signature in database
GPG key ID: 0D4EEACF63D4262E
4 changed files with 90 additions and 76 deletions

27
languages/python.el Normal file
View file

@ -0,0 +1,27 @@
;;; Ruby -- summary
;;; Commentary:
;;; Code:
(require 'elpy)
(defun python-mode-config ()
"Setup editor for Python."
(remove-hook 'ruby-mode-hook 'ruby-mode-config)
(remove-hook 'elixir-mode-hook 'elixir-mode-config)
(remove-hook 'emacs-lisp-mode-hook 'elisp-mode-config)
(remove-hook 'html-mode-hook 'web-mode-config)
(remove-hook 'haskell-mode-hook 'haskell-mode-config)
(remove-hook 'java-mode-hook 'java-mode-config)
(set-indent 4))
(setq elpy-rpc-python-command "python3")
(setq python-indent-guess-indent-offset 4)
(setq python-indent-offset 4)
(add-hook 'python-mode-hook 'python-mode-config)
(add-hook 'python-mode-hook 'pyenv-mode)
(add-hook 'python-mode-hook 'elpy-mode)
(add-hook 'python-mode-hook 'set-width-79)
(provide 'python)
;;; python.el ends here

48
languages/ruby.el Normal file
View file

@ -0,0 +1,48 @@
;;; Ruby -- summary
;;; Commentary:
;;; Code:
(require 'company)
(require 'ruby-mode)
(require 'robe)
(require 'rvm)
(require 'rspec-mode)
(defun ruby-mode-config ()
"Setup editor for Ruby."
(set-indent 2)
;; Do not align 'begin' and 'while' ;;
(setq ruby-align-to-stmt-keywords '(if begin case elseif rescue))
;; Do not indent inside the parenthasis
(setq ruby-deep-indent-paren nil)
;; 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)
;; Use longer lines for HAML
(add-hook 'haml-mode-hook 'set-width-120)
(provide 'ruby)
;;; ruby.el ends here