 ;;
 ;;; Packages
 
-(after! ruby-mode
+(use-package! ruby-mode  ; built-in
+  ;; Other extensions are already registered in `auto-mode-alist' by `ruby-mode'
+  :mode "\\.\\(?:a?rb\\|aslsx\\)\\'"
+  :mode "/\\(?:Brew\\|Fast\\)file\\'"
+  :interpreter "j?ruby\\([0-9.]+\\)"
+  :config
   (setq ruby-insert-encoding-magic-comment nil)
-  (when (require 'enh-ruby-mode nil t)
-    (rassq-delete-all 'ruby-mode interpreter-mode-alist)))
-
-
-(use-package! enh-ruby-mode
-  :mode ("\\.\\(?:pry\\|irb\\)rc\\'" . +ruby-init-h)
-  :mode ("\\.\\(?:rb\\|arb\\|axlsx\\|rake\\|rabl\\|ru\\|builder\\|gemspec\\|podspec\\|jbuilder\\|thor\\)\\'" .  +ruby-init-h)
-  :mode ("/\\(?:Berks\\|Brew\\|Cap\\|Fast\\|Gem\\|Guard\\|Pod\\|Puppet\\|Rake\\|Thor\\|Vagrant\\)file\\'" .  +ruby-init-h)
-  :interpreter ("j?ruby\\([0-9.]+\\)" . +ruby-init-h)
-  :preface
-  (defun +ruby-init-h ()
-    "Enable `enh-ruby-mode' if ruby is available, otherwise `ruby-mode'."
-    (if (executable-find "ruby")
-        (enh-ruby-mode)
-      (ruby-mode)))
-  :config
+
   (set-electric! '(ruby-mode enh-ruby-mode) :words '("else" "end" "elsif"))
   (set-repl-handler! '(ruby-mode enh-ruby-mode) #'inf-ruby)
 
   (when (featurep! +lsp)
-    (add-hook 'enh-ruby-mode-local-vars-hook #'lsp!))
+    (add-hook! '(ruby-mode-local-vars-hook
+                 enh-ruby-mode-local-vars-hook)
+               #'lsp!))
 
   (after! company-dabbrev-code
-    (add-to-list 'company-dabbrev-code-modes 'enh-ruby-mode)
-    (add-to-list 'company-dabbrev-code-modes 'ruby-mode))
+    (pushnew 'company-dabbrev-code-modes 'enh-ruby-mode 'ruby-mode))
 
   (after! inf-ruby
     ;; switch to inf-ruby from compile if we detect a breakpoint has been hit
     (add-hook 'compilation-filter-hook #'inf-ruby-auto-enter))
 
   ;; so class and module pairs work
-  (setq-hook! (ruby-mode enh-ruby-mode) sp-max-pair-length 6))
+  (setq-hook! (ruby-mode enh-ruby-mode) sp-max-pair-length 6)
+
+  (map! :localleader
+        :map (ruby-mode-map enh-ruby-mode-map)
+        "[" #'enh-ruby-toggle-block
+        "{" #'enh-ruby-toggle-block))
+
+
+(use-package! enh-ruby-mode
+  :when (executable-find "ruby")
+  :after ruby-mode
+  :config
+  ;; If ruby is present, `enh-ruby-mode' provides superior (semantic) syntax
+  ;; highlighting so use it instead.
+  (advice-add #'ruby-mode :override #'enh-ruby-mode))
 
 
 (use-package! robe

                  (bound-and-true-p lsp--buffer-deferred))
        (robe-mode +1))))
  :config
  (set-repl-handler! 'enh-ruby-mode #'robe-start)
  (set-company-backend! 'enh-ruby-mode 'company-robe 'company-dabbrev-code)
  (set-lookup-handlers! 'enh-ruby-mode
    :definition #'robe-jump
    :documentation #'robe-doc)
  (map! :localleader



(use-package! rubocop
  :hook (ruby-mode . rubocop-mode)
  :hook (enh-ruby-mode . rubocop-mode)
  :config
  (map! :localleader
