2

In a ruby project. when point is at a ruby symbol, for example UserCart::PromotionService.new(blah blah how can I jump to the definition of that class/module.

american-ninja-warrior
  • 3,773
  • 2
  • 21
  • 40
  • 1
    Normally, this functionality is bound to `M-.`. I have no idea if the mode you're using for editing ruby source code has that functionality and whether it's good enough to look for class definitions, but you can always try it. –  Jul 18 '18 at 15:40
  • I suspect that both http://ctags.sourceforge.net/ and https://github.com/universal-ctags/ctags have ruby parsers. Therefore you could index your project with one of these tools, then follow DoMiNeLa10's answer. – InHarmsWay Jul 18 '18 at 17:33

1 Answers1

2

Found the answer in a youtube

https://www.youtube.com/watch?v=l_gkh3CsbTk

Specifically as a prelude user, what I did was

kill emacs daemon

;; add to personal.el
(prelude-require-packages '(
  robe
))

emacs --daemon
emacs ~/repo/app/controllers/foo_controller.rb
M-x robe-start
M-x robe-mode
place cursor at contant/sumbol
M-x robe-jump-to-module

And sure enough, I was "teleported" to the module definition in the rails application.

Update: As pointed in a previous comment, you can press M-. and save yourself typing robe-jump-to-module

american-ninja-warrior
  • 3,773
  • 2
  • 21
  • 40