IMPORTANT: This is a breaking update for Mac users, as your shell environment will no longer be inherited correctly (with the removal of exec-path-from-shell). The quick fix is: 'bin/doom env refresh'. Also, the set-env! autodef now does nothing (and is deprecated), be sure to remove calls to it in your config. Smaller changes: + This update also adds --no-* switches to doom quickstart + Includes general improvements to the documentation of several bin/doom commands. + Moves doom/reload* commands to core/autoload/config.el + doom/reload-project has been removed (it didn't actually do anything) The breaking change: This update adds an "envvar file" to Doom Emacs. This file is generated by `doom env refresh`, populated with variables scraped from your shell environment (from both non-interactive and interactive sessions). This file is then (inexpensively) loaded at startup, if it exists. + The file is manually generated with `doom env refresh`. + It can be regenerated automatically whenever `doom refresh` is run by running `doom env enable` (`doom env clear` will reverse this and delete the env file). + `doom quickstart` will ask if you want to auto-generate this envvar file. You won't need it if you're confident Emacs will always be started from the correct environment, however. + Your env file can be reloaded from a running Emacs session with `M-x doom/reload-env`. Note: this won't work if the Emacs session you're running it in doesn't have a correct SHELL set. i.e. don't use this to create your first env file! The idea isn't mine -- it's borrowed from Spacemacs -- and was introduced to me in #1053 by @yurimx. I was impressed with it. Prior to this, I was unhappy with exec-path-from-shell (no hate to the dev, I understand its necessity), and 'doom patch-macos' wasn't ideal for mac users (needed to be reapplied every time you update Emacs). What's more, many users (even Linux users) had to install exec-path-from-shell anyway. This solution suffers from none of their shortcomings. More reliable than patch-macos, more performant and complete than exec-path-from-shell, and easily handled by bin/doom.
159 lines
4.4 KiB
EmacsLisp
159 lines
4.4 KiB
EmacsLisp
;;; lang/ruby/config.el -*- lexical-binding: t; -*-
|
|
|
|
;;
|
|
;; Packages
|
|
|
|
(def-package! enh-ruby-mode
|
|
:mode ("\\.\\(?:pry\\|irb\\)rc\\'" . +ruby|init)
|
|
:mode ("\\.\\(?:rb\\|rake\\|rabl\\|ru\\|builder\\|gemspec\\|jbuilder\\|thor\\)\\'" . +ruby|init)
|
|
:mode ("/\\(?:Berks\\|Cap\\|Gem\\|Guard\\|Pod\\|Puppet\\|Rake\\|Thor\\|Vagrant\\)file\\'" . +ruby|init)
|
|
:preface
|
|
(after! ruby-mode (require 'enh-ruby-mode))
|
|
(defun +ruby|init ()
|
|
"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-hook #'lsp!))
|
|
|
|
(after! company-dabbrev-code
|
|
(add-to-list 'company-dabbrev-code-modes 'enh-ruby-mode nil #'eq)
|
|
(add-to-list 'company-dabbrev-code-modes 'ruby-mode nil #'eq))
|
|
|
|
;; so class and module pairs work
|
|
(setq-hook! (ruby-mode enh-ruby-mode) sp-max-pair-length 6))
|
|
|
|
|
|
(def-package! robe
|
|
:unless (featurep! +lsp)
|
|
:hook (enh-ruby-mode . robe-mode)
|
|
:config
|
|
(set-repl-handler! 'enh-ruby-mode #'robe-start)
|
|
(set-company-backend! 'enh-ruby-mode 'company-robe)
|
|
(set-lookup-handlers! 'enh-ruby-mode
|
|
:definition #'robe-jump
|
|
:documentation #'robe-doc)
|
|
(map! :localleader
|
|
:map robe-mode-map
|
|
"'" #'robe-start
|
|
;; robe mode specific
|
|
"h" #'robe-doc
|
|
"rr" #'robe-rails-refresh
|
|
;; inf-enh-ruby-mode
|
|
:prefix "s"
|
|
"f" #'ruby-send-definition
|
|
"F" #'ruby-send-definition-and-go
|
|
"r" #'ruby-send-region
|
|
"R" #'ruby-send-region-and-go
|
|
"i" #'ruby-switch-to-inf))
|
|
|
|
|
|
;; NOTE Must be loaded before `robe-mode'
|
|
(def-package! yard-mode
|
|
:hook (ruby-mode enh-ruby-mode))
|
|
|
|
|
|
(def-package! rubocop
|
|
:hook (enh-ruby-mode . rubocop-mode)
|
|
:config
|
|
(map! :localleader
|
|
:map rubocop-mode-map
|
|
"f" #'rubocop-check-current-file
|
|
"F" #'rubocop-autocorrect-current-file
|
|
"p" #'rubocop-check-project
|
|
"P" #'rubocop-autocorrect-project))
|
|
|
|
|
|
;;
|
|
;; Package & Ruby version management
|
|
|
|
(def-package! rake
|
|
:defer t
|
|
:init
|
|
(setq rake-cache-file (concat doom-cache-dir "rake.cache"))
|
|
(map! :after enh-ruby-mode
|
|
:localleader
|
|
:map enh-ruby-mode-map
|
|
:prefix "k"
|
|
"k" #'rake
|
|
"r" #'rake-rerun
|
|
"R" #'rake-regenerate-cache
|
|
"f" #'rake-find-task))
|
|
|
|
(def-package! bundler
|
|
:defer t
|
|
:init
|
|
(map! :after enh-ruby-mode
|
|
:localleader
|
|
:map enh-ruby-mode-map
|
|
:prefix "b"
|
|
"c" #'bundle-check
|
|
"C" #'bundle-console
|
|
"i" #'bundle-install
|
|
"u" #'bundle-update
|
|
"e" #'bundle-exec
|
|
"o" #'bundle-open))
|
|
|
|
;; `rvm'
|
|
(setq rspec-use-rvm t)
|
|
|
|
(after! rbenv
|
|
(add-to-list 'exec-path (expand-file-name "shims" rbenv-installation-dir)))
|
|
|
|
|
|
;;
|
|
;; Testing frameworks
|
|
|
|
(def-package! rspec-mode
|
|
:mode ("/\\.rspec\\'" . text-mode)
|
|
:init
|
|
(defvar evilmi-ruby-match-tags
|
|
'((("unless" "if") ("elsif" "else") "end")
|
|
("begin" ("rescue" "ensure") "end")
|
|
("case" ("when" "else") "end")
|
|
(("class" "def" "while" "do" "module" "for" "until") () "end")
|
|
;; Rake
|
|
(("task" "namespace") () "end")))
|
|
|
|
(when (featurep! :feature evil)
|
|
(add-hook 'rspec-mode-hook #'evil-normalize-keymaps))
|
|
:config
|
|
(map! :localleader
|
|
:prefix "t"
|
|
:map (rspec-verifiable-mode-map rspec-dired-mode-map rspec-mode-map)
|
|
"a" #'rspec-verify-all
|
|
"r" #'rspec-rerun
|
|
:map (rspec-verifiable-mode-map rspec-mode-map)
|
|
"v" #'rspec-verify
|
|
"c" #'rspec-verify-continue
|
|
"l" #'rspec-run-last-failed
|
|
"T" #'rspec-toggle-spec-and-target
|
|
"t" #'rspec-toggle-spec-and-target-find-example
|
|
:map rspec-verifiable-mode-map
|
|
"f" #'rspec-verify-method
|
|
"m" #'rspec-verify-matching
|
|
:map rspec-mode-map
|
|
"s" #'rspec-verify-single
|
|
"e" #'rspec-toggle-example-pendingness
|
|
:map rspec-dired-mode-map
|
|
"v" #'rspec-dired-verify
|
|
"s" #'rspec-dired-verify-single))
|
|
|
|
|
|
(def-package! minitest
|
|
:defer t
|
|
:config
|
|
(when (featurep! :feature evil)
|
|
(add-hook 'minitest-mode-hook #'evil-normalize-keymaps))
|
|
(map! :localleader
|
|
:map minitest-mode-map
|
|
:prefix "t"
|
|
"r" #'minitest-rerun
|
|
"a" #'minitest-verify-all
|
|
"s" #'minitest-verify-single
|
|
"v" #'minitest-verify))
|