Skip to content

Add typechecker initialization option - #4273

Draft
2Kable wants to merge 1 commit into
Shopify:mainfrom
2Kable:typechecker-initialization-option
Draft

2Kable wants to merge 1 commit into
Shopify:mainfrom
2Kable:typechecker-initialization-option

Conversation

@2Kable

@2Kable 2Kable commented Nov 16, 2026 •

Copy link
Copy Markdown

Motivation

The Ruby LSP treats a project as a Sorbet project whenever sorbet-static is anywhere in the lockfile. When that happens, it leaves constant features (definition, references, rename, workspace symbols, and so on) to the Sorbet LSP, even if the Sorbet LSP doesn't run for that workspace.

This comes up often in monoliths that have sorbet-runtime and Tapioca at the root while Sorbet only type checks a sub-application. Opening the root workspace gives a degraded experience: the Ruby LSP defers to a Sorbet LSP that isn't there.

Today the only way out is the RUBY_LSP_BYPASS_TYPECHECKER env var, which VS Code exposes as rubyLsp.bypassTypechecker. That setting's description says it's "only intended to be used while working on the Ruby LSP itself", and editors other than VS Code have no initialization option for it.

Implementation

  • New boolean initialization option bypassTypechecker (default false), matching the existing VS Code setting.
    • false keeps the current detection (sorbet-static in dependencies).
    • true turns detection off, like the env var does. Both checks live in detect_typechecker.
  • RUBY_LSP_BYPASS_TYPECHECKER still works.
  • If sorbet-static is detected but the workspace has no sorbet/config, the server logs a hint (a window/logMessage during initialization) that points to the option. Behavior doesn't change.
  • VS Code: rubyLsp.bypassTypechecker is now also sent as bypassTypechecker in initializationOptions. The env var wiring stays so older servers keep working. The setting description now describes a supported use case.
  • Docs: jekyll/editors.markdown lists the new option and explains it.

The default behavior doesn't change, so this is backward compatible. The option is a boolean for now to match the existing setting. It could become a string enum (e.g. typechecker: "auto" | "none") later if other type checkers need to be supported; the name and shape are open to maintainer feedback.

Automated Tests

Added unit tests in test/global_state_test.rb for:

  • default auto detection
  • no detection without sorbet-static
  • disabling detection with bypassTypechecker: true
  • the env var still working
  • the hint being logged or not, depending on whether sorbet/config exists

Manual Tests

  1. Open a project that has sorbet-static in its Gemfile.lock but no sorbet/config.
  2. Check the Ruby LSP output channel for the new hint.
  3. Enable rubyLsp.bypassTypechecker and restart the server. The output shows the "Type checker integration disabled by user" message, and go to definition and references on constants are now served by the Ruby LSP.

🤖 Generated with Claude Code

Sorbet detection only checks for sorbet-static in the bundle, so workspaces
that depend on Sorbet without running the Sorbet LSP lose definition,
references, rename and workspace symbols. Accept a `bypassTypechecker`
initialization option so any editor can opt out, keep the
RUBY_LSP_BYPASS_TYPECHECKER env var used by the VS Code extension, and log
when the bypass is active.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@2Kable
2Kable force-pushed the typechecker-initialization-option branch from 77e5f74 to 4f59cdd Compare November 16, 2026 18:47

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant