Allow disabling the Sorbet detection via config #3468
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
When configuring editors other than VS Code (e.g. Zed or Emacs), sometimes running multiple LSPs isn't an option. This means that Sorbet-enabled projects aren't able to run both Ruby LSP and Sorbet LSP.
In those cases, it's convenient to be able to disable the deference for some features to the type checker LSP. Prior to this change, you could accomplish this by setting the
RUBY_LSP_BYPASS_TYPECHECKER
environment variable, which works but isn't the easiest thing to do in all cases (e.g. you can't launch Zed from Spotlight unless you globally set this value, which then disables Sorbet deference in all projects).Instead of hiding this behavior behind an environment variable, this change makes it configurable via an initialization option.
Implementation
This change introduces a new initialization option for disabling the automatic detection of a type checker. This behavior was initially implemented through an environment variable (which this change maintains for backwards-compatibility), but that isn't the easiest thing to configure.
By making it a part of initialization, we can now declaratively set the flag with all other configuration for the server.
I went with the naming of "defer" and "bypass" because the default behavior is to defer some functionality to the type checker and the alternative is to bypass with it. While these are communicative, I'm unsure if they're discoverable.
Automated Tests
I added all cases for this behavior to the
GlobalState
test suite.Manual Tests
Use this configuration in a Sorbet-enabled project:
and observe that Ruby LSP handles go-to-symbol and workspace symbols.