dgutov / robe

Code navigation, documentation lookup and completion for Ruby
584 stars 37 forks source link

Use projectile root when other Ruby markers do not exist #117

Closed ivar closed 4 years ago

ivar commented 5 years ago

This is a feature enhancement request. I came here looking for help with this issue . I'm working on a standalone Ruby script and I would like to fire up a repl. Unfortunately, none of the markers that Robe looks for make sense in my project so perhaps Robe could use the same project root as projectile, or perhaps use Emacs's native setting? (I am still learning Emacs so I don't know which would be correct)

dgutov commented 5 years ago

How would Robe fire a REPL just by knowing a project root?

You can do it yourself, though: open the script, then press C-c C-s. M-x robe-start should pick it up after that.

ivar commented 5 years ago

The goal of this request is to allow people who want to mess around with a repl to be able to open one in any 'project'. The "No matching directory found" error is confusing because it is not intuitive that you would need Ruby project markers for a repl to start. When I saw issue #114 I thought that using the project root as a fallback would be a good solution.

In terms of starting up a repl manually, that's certainly possible but the normal way I'd go about this is via the Ruby layer (which uses Robe) in spacemacs. The maintainer(s) of the Ruby layer expect robe-start to successfully start the repl using their approach - which brings up the "No Ruby console running. Launch automatically?" confirmation, which fails without the Ruby marker. Do you think I would be more appropriate for me to look at asking for changes the spacemacs behaviour ?

btw - thanks for this project, it's cool to learn the ways of emacs/spacemacs with good support for fun languages like Ruby :)

dgutov commented 5 years ago

But it's not trying to start "a REPL". You don't need a project for that anyway.

It's trying to launch an appropriate project REPL. Not having found a type of project it knows about, however, it gives up. I'm not sure launching a "whatever" REPL is going to be an appropriate alternative, considering the user's code definitely won't be loaded into it.

Do you think I would be more appropriate for me to look at asking for changes the spacemacs behaviour?

Not sure what they could do better, to be honest.

btw - thanks for this project

You're welcome!

dgutov commented 4 years ago

Now, as a user, you can invoke M-x inf-ruby in advance (which would simply launch irb), but that would limit this package's knowledge about your project and its modules/classes/methods/dependencies. You can do that, for example if you're content with only some help with stdlib, and/or you're fine with loading files and typing require 'certain_lib' in the REPL manually.

But that's not a choice that Spacemacs, or Doom, or any other distribution should make. I think they should treat it more like SLIME, with separate bindings for creating a REPL: https://github.com/syl20bnr/spacemacs/blob/c7a103a772d808101d7635ec10f292ab9202d9ee/layers/%2Blang/common-lisp/README.org#repl

Now, they also have the choice of using LSP with Solargraph instead. It's basically hands-off, starts automatically (as the protocol expects), though it comes with its own tradeoffs WRT functionality.

dgutov commented 4 years ago

And looking at https://develop.spacemacs.org/layers/+lang/ruby/README.html#choosing-a-backend, they already provide this choice.

People who want to use robe-mode nevertheless with ad-hoc projects, should learn to M-x inf-ruby. As well as the binding for ruby-load-file, to load their files into the REPL.