Sorbet

Sorbet

  • Get started
  • Docs
  • Try
  • Community
  • GitHub
  • Blog

›Editor Features

Getting Started

  • Overview
  • Adopting Sorbet
  • Tracking Adoption
  • Quick Reference
  • Visual Studio Code
  • TypeScript ↔ Sorbet

Static & Runtime

  • Gradual Type Checking
  • Enabling Static Checks
  • Enabling Runtime Checks
  • RBI Files
  • CLI Quickstart
  • CLI Reference
  • Runtime Configuration

Troubleshooting

  • Troubleshooting
  • Why type annotations?
  • FAQ
  • Error Reference
  • Unsupported Ruby Features

Type System

  • sig
  • Type Annotations (non-sig)
  • T.let, T.cast, T.must, T.bind
  • Class Types (Integer, String)
  • Arrays & Hashes
  • Nilable Types (T.nilable)
  • Union Types (T.any)
  • Flow-Sensitivity (is_a?, nil?)
  • T.type_alias
  • Exhaustiveness (T.absurd)
  • T::Struct
  • T::Enum
  • T.untyped
  • Blocks, Procs, & Lambdas
  • Abstract Classes & Interfaces
  • Final Methods & Classes
  • Override Checking
  • Sealed Classes
  • T.class_of
  • T.self_type
  • T.noreturn
  • T.anything
  • T.attached_class
  • Intersection Types (T.all)
  • Generics
  • T::NonForcingConstants
  • Banning untyped

Editor Features

  • Language Server (LSP)
  • Server Status
  • LSP & Typed Level
  • Go to Definition
  • Hover
  • Autocompletion
  • Find All References
  • Code Actions
  • Outline & Document Symbols
  • Documentation Comments
  • Suggesting sigs
  • Highlighting untyped
  • sorbet: URIs

Experimental Features

  • Tuples
  • Shapes
  • Overloads
  • Requiring Ancestors
  • RBS Comments
Edit

Types and documentation on Hover

Sorbet can show the types and documentation for parts of the program via the LSP Hover feature.

View on sorbet.run →

The key features:

  • Shows type information

  • Shows associated documentation (excludes local variables).

    See Documentation Comments for more information.

  • Markdown support (conditional on language client)

    Consult the docs for your language client to ensure whether it requests Hover results in Markdown or plain text. Some terminal-based clients request plain text.

    (Sorbet surfaces comment content unchanged, which may or may not use Markdown syntax. It only wraps types in Markdown fenced code blocks if the client supports it.)

Troubleshooting

VS Code shows “Loading…”

Sorbet will only show Hover results when it is in the Idle or Typechecking in background... states.

Read about all of Sorbet’s server statuses for more information on these states.

If Sorbet is in the Idle state and hovering still shows Loading..., that usually suggests a bug in Sorbet. Double check whether the server process crashed, or whether Sorbet is using excessive CPU cycles (Sorbet should consume virtually no CPU cycles when Idle).

No hover results

Is the file # typed: false or # typed: ignore? Hover support is degraded in these files. Similarly, is the call site untyped? If so, consider troubleshooting why.

See Feature support by strictness level to learn what’s expected.

If the file is # typed: true, the server is in the Idle status, and there are still no results, this could either be that there is nothing under the cursor (expected), or that Sorbet mistakenly thinks there’s nothing under the cursor (unexpected, please file a bug).

Hover isn’t showing documentation comments

Double check that there isn’t a blank line between the documentation comment and the definition.

Otherwise, read Documentation Comments to confirm what the expected behavior is, and consider reporting a bug.

← Go to DefinitionAutocompletion →
  • Troubleshooting
    • VS Code shows "Loading..."
    • No hover results
    • Hover isn't showing documentation comments

Get started · Docs · Try · Community · Blog · Twitter