get rid of ruby-mode by using enh-ruby-mode

This commit is contained in:
Sameer Rahmani 2016-01-09 11:51:20 +03:30
parent 26b1e5efcf
commit c58df5fed9
5 changed files with 38 additions and 24 deletions

View File

@ -4,7 +4,7 @@
;; Dependencies ----------------------------------
(depends-on 'company-inf-ruby)
(depends-on 'ruby-mode)
(depends-on 'enh-ruby-mode)
(depends-on 'rbenv)
(depends-on 'slim-mode)
(depends-on 'haml-mode)

View File

@ -3,12 +3,10 @@
;; Functions -------------------------------------------------
;;;###autoload
(defun ruby-mode-callback ()
(defun enh-ruby-mode-callback ()
(setup-general-ruby-editor)
(setup-inf-ruby)
(setup-bundler)
(setq ruby-deep-indent-paren t)
(with-ability rbenv
(require 'rbenv)
@ -17,12 +15,14 @@
(with-ability auto-pair
(ruby-electric-mode t)))
;;;###autoload
(defun extensions/ruby-initialize ()
"Web development plugin initialization."
(message "Initializing 'ruby' extension.")
(require 'enh-ruby-mode)
(autoload 'enh-ruby-mode "enh-ruby-mode" "Major mode for ruby files" t)
(with-ability global-rbenv
(require 'rbenv)
(global-rbenv-mode))
@ -30,13 +30,20 @@
(ability ruby-editor ('flycheck)
"Gives FG42 the ability to edit ruby files."
;; Autostart ruby mode on these file types
(add-to-list 'auto-mode-alist '("\\.rake$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Gemfile$" . 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 '("config.ru$" . ruby-mode))
(add-to-list 'auto-mode-alist '("json.jbuilder$" . ruby-mode))
(dolist (spec '(("\\.rb$" . enh-ruby-mode)
("[vV]agrantfile$" . enh-ruby-mode)
("[gG]emfile$" . enh-ruby-mode)
("[pP]uppetfile$" . enh-ruby-mode)
("\\.rake$" . enh-ruby-mode)
("\\.rabl$" . enh-ruby-mode)
("[cC]apfile$" . enh-ruby-mode)
("\\.gemspec$" . enh-ruby-mode)
("\\.builder$" . enh-ruby-mode)))
(add-to-list 'auto-mode-alist spec))
(setq enh-ruby-use-encoding-map nil
;; don't deep indent arrays and hashes
enh-ruby-deep-indent-paren nil)
;; Autostart yaml-mode
(add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))
@ -44,20 +51,20 @@
'(lambda ()
(define-key yaml-mode-map "\C-m" 'newline-and-indent)))
;; Add our callback to ruby-mode-hook
(add-hook 'ruby-mode-hook 'ruby-mode-callback)
;; Add our callback to enh-ruby-mode-hook
(add-hook 'enh-ruby-mode-hook 'enh-ruby-mode-callback)
;; configure hs-minor-mode
(add-to-list 'hs-special-modes-alist
'(ruby-mode
'(enh-ruby-mode
"\\(class\\|def\\|do\\|if\\)" "\\(end\\)" "#"
(lambda (arg) (ruby-end-of-block)) nil))
(add-hook 'ruby-mode-hook 'projectile-mode))
(add-hook 'enh-ruby-mode-hook 'projectile-mode))
(ability ruby-code-completion ('code-completion)
"Auto complete ruby code on demand."
(add-to-list 'ruby-mode-hook 'ruby-code-completion))
(add-to-list 'enh-ruby-mode-hook 'ruby-code-completion))
(ability slim-mode ()
"Gives FG42 the ability to edit slim templates."

View File

@ -10,11 +10,11 @@
(defun setup-bundler ()
"Setup bundler and its keybindings"
(require 'bundler)
(define-key ruby-mode-map (kbd "\C-c b i") 'bundle-install)
(define-key ruby-mode-map (kbd "\C-c b u") 'bundle-update)
(define-key ruby-mode-map (kbd "\C-c b e") 'bundle-exec)
(define-key ruby-mode-map (kbd "\C-c b o") 'bundle-open)
(define-key ruby-mode-map (kbd "\C-c b c") 'bundle-console))
(define-key enh-ruby-mode-map (kbd "\C-c b i") 'bundle-install)
(define-key enh-ruby-mode-map (kbd "\C-c b u") 'bundle-update)
(define-key enh-ruby-mode-map (kbd "\C-c b e") 'bundle-exec)
(define-key enh-ruby-mode-map (kbd "\C-c b o") 'bundle-open)
(define-key enh-ruby-mode-map (kbd "\C-c b c") 'bundle-console))
;;;###autoload
(defun setup-inf-ruby()
@ -27,7 +27,7 @@
(global-set-key (kbd "C-c r r") 'inf-ruby)
;; TODO: We don't need this if pry setup is present in ~/.irbrc
(setq irbparams " --inf-ruby-mode -r irb/completion")
(setq irbparams " --inf-enh-ruby-mode -r irb/completion")
(setq irbpath (rbenv--expand-path "shims" "irb"))
(setq irb (concat irbpath irbparams))
(add-to-list 'inf-ruby-implementations (cons "ruby" irb))
@ -56,7 +56,7 @@
'(rspec-install-snippets))
(ruby-tools-mode t)
(define-key ruby-mode-map (kbd "C-.") 'insert-arrow)
(define-key enh-ruby-mode-map (kbd "C-.") 'insert-arrow)
(hs-minor-mode t)
;; Hack autocomplete so it treat :symbole and symbole the same way
(modify-syntax-entry ?: "."))

View File

@ -48,5 +48,10 @@ local should be 't' if theme is on FG42 it self"
(if (file-exists-p file)
(load-file file)))
(defun what-face (pos)
(interactive "d")
(let ((face (or (get-char-property (point) 'read-face-name)
(get-char-property (point) 'face))))
(if face (message "Face: %s" face) (message "No face at %d" pos))))
(provide 'fg42/base)

View File

@ -49,6 +49,8 @@ Based on the TextMate theme Monokai"
(font-lock-preprocessor-face ((t (:foreground "#66D9EF")))) ; aluminum
(font-lock-constant-face ((t (:foreground "#4e9a06")))) ; dark chameleon
(font-lock-type-face ((t (:foreground "#66D9EF")))) ; light plum
(enh-ruby-op-face ((t (:foreground "#dfdfda" :background nil))))
(font-lock-warning-face ((t (:bold t :foreground "#cc0000")))) ; scarlet red
(hl-line ((t (:background "#393b2f"))))