Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add chruby support to Ruby layer #2321

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions contrib/!lang/ruby/README.org
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,17 @@ specific documentation for details and caveats):

** Ruby version management

This layer supports the use of [[https://rvm.io/][RVM]] and [[https://github.com/sstephenson/rbenv][Rbenv]].
To enable it, set the =ruby-version-manager= var in your =~/.spacemacs=:
This layer supports the use of [[https://rvm.io/][RVM]], [[https://github.com/sstephenson/rbenv][Rbenv]],
and [[https://github.com/postmodern/chruby][Chruby]]. To enable it, set the
=ruby-version-manager= var in your =~/.spacemacs=:

#+BEGIN_SRC emacs-lisp
(defun dotspacemacs/init ()
(setq-default ruby-version-manager 'rbenv)
)
#+END_SRC

Possible values are =rbenv= and =rvm=.
Possible values are =rbenv=, =chruby=, and =rvm=.

* Key bindings

Expand Down
8 changes: 8 additions & 0 deletions contrib/!lang/ruby/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@
:config (add-hook 'enh-ruby-mode-hook
(lambda () (rbenv-use-corresponding)))))

(defun ruby/init-chruby ()
"Initialize chruby mode"
(use-package chruby
:defer t
:init (chruby)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to call chruby here.
defer t enable deferred loading so chruby will be loading when the first ruby file is opened.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you can delete this line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally didn't have this line and it was not working. I am new to emacs and elisp so am probably missing something in my mental model, but it didn't work without this line...

:config (add-hook 'enh-ruby-mode-hook
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to replace :config by :init otherwise the function won't be hooked at initialization time (ie before the actual loading of the package).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I literally copied this from the rbenv example right above it. Can you help me understand what makes it different in this case?

(lambda () (chruby-use-corresponding)))))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need the lambda expression here you can replace it by 'chruby-use-corresponding. The lambda expression (or a named function) is needed only when you have to pass arguments to the function to hook.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup I can change that, I was trying to be consistent with the rbenv expression directly above this.


(defun ruby/init-rvm ()
"Initialize RVM mode"
(use-package rvm
Expand Down