Shopify / ruby-lsp

An opinionated language server for Ruby
https://shopify.github.io/ruby-lsp/
MIT License
1.63k stars 168 forks source link

Allow Sorbet + Ruby LSP to work together for Go To Definition. #2689

Open Overload119 opened 1 month ago

Overload119 commented 1 month ago

Description

Ruby LSP Information

Ruby LSP Information

VS Code Version

1.94.0

Ruby LSP Extension Version

0.8.2

Ruby LSP Server Version

0.19.1

Ruby LSP Addons

Ruby Version

3.2.2

Ruby Version Manager

rbenv

Installed Extensions

Click to expand - better-comments (3.0.2) - vscode-theme-onedark (2.3.0) - Bookmarks (13.5.0) - auto-add-brackets (0.12.2) - vscode-mjml (1.6.0) - markdown-mermaid (1.25.0) - pgformatter (1.28.1) - vscode-navigate-edit-history (1.6.3) - vscode-eslint (3.0.10) - prettier-vscode (11.0.0) - auto-rename-tag (0.1.10) - vscode-pull-request-github (0.98.0) - go (0.42.1) - gc-excelviewer (4.2.62) - save-restore-editors (1.5.3) - plantuml (2.18.1) - copyfilename (1.0.0) - haml (1.4.1) - vscode-rdbg (0.2.2) - codeacejumper (3.3.2) - vscode-scss (0.10.0) - vscode-typescript-next (5.7.20241006) - vsliveshare (1.0.5941) - bun-vscode (0.0.15) - vscode-yaml-sort (6.5.17) - vscode-yaml (1.15.0) - block-travel (0.0.2) - ruby-extensions-pack (0.1.12) - ruby-lsp (0.8.2) - vscode-fileutils (3.10.3) - sorbet-vscode-extension (0.3.37) - cody-ai (1.36.3) - sass-indented (1.8.31) - vscode-open-in-github (1.18.0) - vscode-mermaid-editor (0.19.1) - gitblame (11.1.0) - vscode-todo-highlight (1.0.5) - vscode-markdown-everywhere (0.0.15)

Ruby LSP Settings

Click to expand ##### Workspace ```json { "enabledFeatures": { "codeActions": true, "diagnostics": true, "documentHighlights": true, "documentLink": true, "documentSymbols": true, "foldingRanges": true, "formatting": false, "hover": true, "inlayHint": true, "onTypeFormatting": false, "selectionRanges": true, "semanticHighlighting": true, "completion": true, "codeLens": false, "definition": false, "workspaceSymbol": true, "signatureHelp": true, "typeHierarchy": true }, "rubyVersionManager": { "identifier": "rbenv" }, "formatter": "none" } ``` ##### User ```json { "enableExperimentalFeatures": false, "enabledFeatures": { "codeActions": true, "diagnostics": true, "documentHighlights": true, "documentLink": true, "documentSymbols": true, "foldingRanges": true, "formatting": false, "hover": true, "inlayHint": true, "onTypeFormatting": false, "selectionRanges": true, "semanticHighlighting": true, "completion": true, "codeLens": false, "definition": false, "workspaceSymbol": true, "signatureHelp": true, "typeHierarchy": true }, "featuresConfiguration": {}, "addonSettings": {}, "rubyVersionManager": { "identifier": "rbenv" }, "customRubyCommand": "", "formatter": "none", "linters": null, "bundleGemfile": "", "testTimeout": 30, "branch": "", "pullDiagnosticsOn": "both", "useBundlerCompose": false, "bypassTypechecker": false, "rubyExecutablePath": "/Users/amirsharif/.rbenv/shims/ruby", "indexing": {}, "erbSupport": true } ```

Reproduction steps

  1. Cmd+Hover over a Symbol.

Image

I thought that this extension will work with Sorbet. However, Sorbet's extension will not show hover information on an untyped file. Despite that, it looks like RubyLSP still understands where the definition is.

Is there a way to get these two to play together?

marknuzz commented 1 month ago

What version of sorbet are you using in your project? The text was updated recently, from "Hover, Go To Definition, and other features are disabled in this file.", to "Most Hover results will not appear until the file is # typed: true or higher.". It seems to work better with typed: false files as well. Try updating it and see if the issue persists.

There's also this docs page, but it seems to make no difference for me now perhaps due to the recent update.

vinistock commented 1 month ago

Thank you for the report! We already should be providing definition on typed: false files. We check for that here.

Are you not able to go to definition on any methods for typed: false files?