solargraph icon indicating copy to clipboard operation
solargraph copied to clipboard

RBS Support

Open castwide opened this issue 3 years ago • 13 comments

Integration of RBS into Solargraph is officially on the roadmap.

Features

  • Map the Ruby core and stdlib with RBS
  • Map gems with RBS when sigs are available
  • Fall back to YARD for gems that do not provide sigs

Pros

  • Ostensibly faster. In my early experiments, mapping from RBS instead of YARD appears to provide a slight performance boost.
  • Better support. Updates to core and stdlib signatures are likely to be more frequent and more accurate.
  • No need for core docs. It will no longer be necessary to use solargraph download-core to update core and stdlib documentation.
  • YARD will continue to be supported. RBS sigs will be treated as the canonical authority for external libraries when they're available, but Solargraph will still use YARD annotation in workspace maps.

Cons

  • Requires Ruby 2.6+. Solargraph currently supports Ruby 2.4+. With integration of RBS, 2.6 will become the minimum requirement.
  • Major rearchitecture. The concepts of maps and pins will undergo a thorough redesign.
  • Missing features. Some code intelligence provided by YARD may not be currently available in RBS. One known example: RBS does not support protected methods.

Current progress can be previewed on the repo's rbs branch.

castwide avatar Jul 24 '21 17:07 castwide

Do you have any plans to support generating RBS files from YARD docs?

Thanks for all the work. This gem is a huge help!

dlealmt avatar Nov 30 '21 10:11 dlealmt

@dleal-mojotech Thanks!

If I do, it will probably be based on Sord.

castwide avatar Nov 30 '21 11:11 castwide

I've been using sord with a decent degree of success.

wagenet avatar Dec 15 '21 16:12 wagenet

Any update on rbs support? rbs is working really well on rubymine and I miss it in vscode :)

tmszcncl avatar Sep 22 '22 14:09 tmszcncl

It's still in progress. I just updated the rbs branch with a few commits I hadn't pushed yet. I can't give an exact ETA yet, but certainly before the end of the year.

castwide avatar Sep 24 '22 15:09 castwide

steep seems to be the way things are going with rbs. I use RubyMine at home but work uses something resembling VSCode. I like the idea of rbs but I'm honestly wondering if there should've been a language break at 3 to support gradual typing like Crystal and Python.

skull-squadron avatar Sep 27 '22 02:09 skull-squadron

The rbs branch is merged into master and will be released shortly. Some notes on the current version:

  • The core and stdlib maps are generated from RBS. This means it is no longer necessary to download or generate core documentation.
  • Support for RBS is not implemented in gems and workspaces yet. This is a little trickier for several reasons. One major issue is that RBS does not inherently support code locations, so features like go to definition would either stop working or point to the RBS definition instead of the code. I'm currently looking into possible hybrid solutions.
  • The deprecated RuboCop args are fixed (#606).
  • The minimum Ruby requirement is now 2.6.

castwide avatar Jan 02 '23 17:01 castwide

Any update on releasing a new cut of Solargraph with support for RBS or is this blocked on the go to definition point?

gwillcox-r7 avatar Jan 20 '23 16:01 gwillcox-r7

I plan to release a version with RBS support for core and stdlib first, then iterate support for gems and workspaces.

castwide avatar Jan 20 '23 21:01 castwide

It looks like v0.49.0 prints the following message on solargraph bundle.

The `bundle` command is deprecated. Solargraph currently uses RBS instead.

There doesn't seem to be any info on what that means (or what to do about it). Is there any documentation available?

chalmagean avatar Apr 10 '23 07:04 chalmagean

Running solargraph bundle should no longer be necessary. I left it as a noop to avoid breaking existing workflows.

For problems specific to Rails, try installing the solargraph-rails plugin first.

castwide avatar Apr 10 '23 08:04 castwide

Gotcha. Thank you.

chalmagean avatar Apr 10 '23 12:04 chalmagean

Is it possible to update solargraph's RBS dependency to something in the RBS 3.x series? That would make packaging solargraph for arch linux, a rolling release distro, much easier. Thanks!

mnussbaum avatar Jan 04 '24 16:01 mnussbaum