diff --git a/emacs/.emacs.d/config/init-ruby.el b/emacs/.emacs.d/config/init-ruby.el index 06486af..f915dc6 100644 --- a/emacs/.emacs.d/config/init-ruby.el +++ b/emacs/.emacs.d/config/init-ruby.el @@ -12,41 +12,21 @@ ("Guardfile\\'" . ruby-mode) ("Capfile\\'" . ruby-mode) ("Vagrantfile\\'" . ruby-mode)) - :hook (ruby-mode . highlight-indent-guides-mode) - :config - (defun toggle-spec-file () - "Find the spec file for the current non-spec buffer or the file under test for the current spec buffer." - (interactive) - (let* ((dir (if-let ((proj (project-current))) - (project-root proj) - default-directory)) - (ext (file-name-extension (buffer-file-name))) - (filename-base (file-name-base (buffer-file-name))) - (spec? (s-ends-with? "_spec" filename-base)) - (rx (if spec? - (format "%s.%s$" (s-chop-suffix "_spec" filename-base) ext) - (format "%s_spec.%s$" filename-base ext))) - (candidates (directory-files-recursively dir rx))) - (cond ((= (length candidates) 0) - (message "No matching file found")) - ((= (length candidates) 1) - (find-file (car candidates))) - (t - (let ((choice (consult--read candidates - :prompt "Find file: " - :category 'file))) - (find-file choice)))))) - :general - (ruby-mode-map "C-c C-t" #'toggle-spec-file)) + :hook (ruby-mode . highlight-indent-guides-mode)) (use-package inf-ruby :commands (inf-ruby inf-ruby-console-auto) :general - ([remap inf-ruby] #'inf-ruby-console-auto)) + ([remap inf-ruby] #'inf-ruby-console-auto) + :hook (after-init . inf-ruby-switch-setup)) (use-package rbenv :hook (after-init . global-rbenv-mode) :custom (rbenv-show-active-ruby-in-modeline nil)) +(use-package rspec-mode + :custom + (rspec-use-opts-file-when-available nil)) + (provide 'init-ruby)