ruby-lsp icon indicating copy to clipboard operation
ruby-lsp copied to clipboard

Add Basic RBS Support

Open andyw8 opened this issue 1 year ago • 1 comments

We rely on RBS for features such as documentation and completion for Ruby's own API.

For example, in VS Code, if you right-click on String.pp and choose "Go to Definition", the editor will show results for kernel.rbs and string.rbs.

But if you open that file, you'll notice there is no syntax highlighting, and no other Ruby LSP features are available.

We can add some improvements. These will work similar to the corresponding Ruby features, but since the RBS syntax is simpler, they should be much easier to implement.

(For now we are focusing on reading/navigation RBS, rather than writing it.)

Grammar file

We can base this off the existing VS Code extension for RBS: https://github.com/soutaro/vscode-rbs-syntax/blob/master/syntaxes/rbs.tmLanguage.json (or perhaps this).

We can also add tests, similar to the tests we have for Ruby grammar here.

Go To Definition

For an RBS signature which references another type, we can implement Go To Definition to provide easy navigation.

Hover

Hovering over a type can show any documentation comments.

DocumentSymbol

Similar to what we do for Ruby code, we can implement DocumentSymbol for RBS to power features such as Outline and Go To Symbol.


(this issue is a subset of https://github.com/Shopify/ruby-lsp/issues/1206)

andyw8 avatar Oct 24 '24 18:10 andyw8

Hi, this effort should be great for so many Rubyists! 👏🏼

JFYI, the grammar file in soutaro/vscode-rbs-syntax is also used by GitHub Linguist:

  • https://github.com/github-linguist/linguist/blob/f164d13fa618023ecf2d8f2ed9a6ce5fae731346/grammars.yml#L1231
    vendor/grammars/vscode-rbs-syntax:
    
  • https://github.com/github-linguist/linguist/pull/6369

ybiquitous avatar Oct 25 '24 00:10 ybiquitous

This issue is being marked as stale because there was no activity in the last 2 months

github-actions[bot] avatar Dec 24 '24 12:12 github-actions[bot]

This issue is being marked as stale because there was no activity in the last 2 months

github-actions[bot] avatar Mar 04 '25 12:03 github-actions[bot]