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

;;
;;; Packages

(after! ruby-mode
  (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!))

  (after! company-dabbrev-code
    (add-to-list 'company-dabbrev-code-modes 'enh-ruby-mode)
    (add-to-list 'company-dabbrev-code-modes '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))


(use-package! robe

(use-package! bundler
  :defer t
  :init
  (map! :after ruby-mode
        :localleader
        :map (ruby-mode-map enh-ruby-mode-map)
        :prefix "b"
        "c" #'bundle-check
        "C" #'bundle-console
