All Projects → dgutov → Robe

dgutov / Robe

Code navigation, documentation lookup and completion for Ruby

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Robe

Nox
Nox is a lightweight, high-performance LSP client for Emacs
Stars: ✭ 181 (-65.52%)
Mutual labels:  code-completion, emacs
Clj Suitable
ClojureScript "IntelliSense" support for JS objects and their properties/methods. Via figwheel and Emacs CIDER.
Stars: ✭ 82 (-84.38%)
Mutual labels:  code-completion, emacs
Vim Practice
💘 Vim is awesome! Here is my practice and study log.
Stars: ✭ 452 (-13.9%)
Mutual labels:  emacs
Docker.el
Manage docker from Emacs.
Stars: ✭ 511 (-2.67%)
Mutual labels:  emacs
Spacemacs Private
My Spacemacs config
Stars: ✭ 480 (-8.57%)
Mutual labels:  emacs
Helm Dash
Browse Dash docsets inside emacs
Stars: ✭ 455 (-13.33%)
Mutual labels:  emacs
Remacs
Rust ❤️ Emacs
Stars: ✭ 4,503 (+757.71%)
Mutual labels:  emacs
Frontmacs
Package-based, web-centric, customizable, awesome-by-default, acceptance-tested Emacs distribution
Stars: ✭ 445 (-15.24%)
Mutual labels:  emacs
Deft
Deft for Emacs
Stars: ✭ 521 (-0.76%)
Mutual labels:  emacs
Emacs 101 Beginner Survival Guide
Emacs 101 新手求生指南 - 一本讓你學 Emacs 不再學得靠北靠母的美好的新手求生指南
Stars: ✭ 472 (-10.1%)
Mutual labels:  emacs
Prelude
Prelude is an enhanced Emacs 25.1+ distribution that should make your experience with Emacs both more pleasant and more powerful.
Stars: ✭ 4,735 (+801.9%)
Mutual labels:  emacs
Emacs Color Themes
A collection of custom themes for Emacs. All the themes are named after famous programmers.
Stars: ✭ 469 (-10.67%)
Mutual labels:  emacs
Filestash
🦄 A modern web client for SFTP, S3, FTP, WebDAV, Git, Minio, LDAP, CalDAV, CardDAV, Mysql, Backblaze, ...
Stars: ✭ 5,231 (+896.38%)
Mutual labels:  emacs
Elsa
Emacs Lisp Static Analyzer
Stars: ✭ 485 (-7.62%)
Mutual labels:  emacs
Anki Editor
Emacs minor mode for making Anki cards with Org
Stars: ✭ 453 (-13.71%)
Mutual labels:  emacs
Import Js
A tool to simplify importing JS modules
Stars: ✭ 511 (-2.67%)
Mutual labels:  emacs
Spacemacs
A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
Stars: ✭ 21,906 (+4072.57%)
Mutual labels:  emacs
Quelpa
Build and install your Emacs Lisp packages on-the-fly directly from source
Stars: ✭ 455 (-13.33%)
Mutual labels:  emacs
Spacemacs Theme
Light and dark theme for spacemacs that supports GUI and terminal
Stars: ✭ 483 (-8%)
Mutual labels:  emacs
Php Mode
A powerful and flexible Emacs major mode for editing PHP scripts
Stars: ✭ 522 (-0.57%)
Mutual labels:  emacs

Robe Build Status MELPA

Robe is a code assistance tool that uses a Ruby REPL subprocess with your application or gem code loaded, to provide information about loaded classes and modules, and where each method is defined.

Generally, you'll want to start with M-x inf-ruby-console-auto. If there's no Ruby console running, most interactive commands provided by Robe will offer to launch it automatically.

The exceptions are code completion and eldoc, which only work if the server is already running. To launch it, type M-x robe-start.

As you change the code in your project, you'll want to update the running process. To load the current file, type C-c C-l (ruby-load-file), see inf-ruby for more commands. When you're working on a Rails project, you can type C-c C-k instead to reload the whole environment at once.

Features

  • Jump to method definition
  • Jump to super or a constructor called at point
  • Jump to a module/class/constant definition
  • Display method documentation
  • Display information about method called at point using ElDoc
  • Method and constant name completion
  • Jumping and completion for instance and local variable names, using simple regexp search in the current file

To see the available commands, type M-x describe-package RET robe RET.

Details

When performing one of the commands defined here, we either need to narrow the method name at point down to a specific method in a specific module, or enumerate the possible method names or constants allowed at point (for code completion).

To do that, we look at the contents of the buffer, and the context at point: in which method it is, of which class, and if it's in singleton class context. Then we look at the method call at point.

If the method call target is implicit (there's no target or the method is super), or the call target is obvious (Foo.new, self.foo), then we first try to look for the definition in the inheritance hierarchy of the target class. Otherwise, or if the initial search yields no result, scan all defined classes and modules.

Depending on the command, if the result is ambiguous, you're either prompted to resolve the ambiguity manually, or the results are merged together.

Install

Set up MELPA if you haven't already, then type M-x package-install RET robe RET.

In the init file:

(add-hook 'ruby-mode-hook 'robe-mode)

or

(global-robe-mode)

Dependencies

  • pry >= 0.10
  • pry-doc >= 0.6.0 (for stdlib docs on MRI; optional)
  • webrick >= 1.5.0 (for ruby >= 3.0.0; WEBrick was removed from the standard library in 3.0.0)

Note that if your project is using Bundler, the dependencies have to be added to the Gemfile.

Completion

company-mode (screenshot):

(eval-after-load 'company
  '(push 'company-robe company-backends))

auto-complete:

(add-hook 'robe-mode-hook 'ac-robe-setup)

Both of the above work only when the connection to the Ruby subprocess has been established. To do that, either use one of the core Robe commands, or type M-x robe-start.

Built-in completion (triggered with C-M-i) is also supported, no extra setup required.

Integration with rvm.el

rvm.el may not have activated the correct project Ruby before robe-start runs.

Either manually run M-x rvm-activate-corresponding-ruby before starting Robe, or advise inf-ruby-console-auto to activate rvm automatically.

(advice-add 'inf-ruby-console-auto :before #'rvm-activate-corresponding-ruby)

Compatibility

  • Tested in Emacs 24.4+, with Ruby 1.9.3-2.6, on GNU/Linux.
  • Essential features work with JRuby, though the startup is longer.
  • Mostly works on MS Windows, with minor glitches.
  • Built-in ruby-mode works best, enh-ruby-mode is not recommended (it breaks the detection of the current context, see #47 and enhanced-ruby-mode#96).

Notes

  • We can't jump to methods defined in C (such as most of the core classes). To read their docs, install pry-doc or add it to your Gemfile.
  • We can't jump to lazily defined methods, such as model.column or find_by_ ActiveRecord methods, before they've been called. This is treatable, but low priority.
  • Jumping to methods defined with Module#delegate just brings us to the place where delegate is called, which is accurate, but often less than useful.
  • To work on several projects in the same Emacs session, you'll have to create the Ruby console for each project after the first one manually with M-x inf-ruby-console-auto. Otherwise, the first one will be used for all Ruby files, with suboptimal results.
  • We may get the context wrong for code inside a block if the method it's passed to uses instance_eval or instance_exec.

TODO

  • Handle delegate and send, Class.new.method and self.class.method.
  • For methods defined through macros, optionally jump to where the macro was called, instead of its definition?
  • Apropos search for classes and methods.
  • Type inference.

Copying

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with GNU Emacs; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].