Skip to content

type-ruby/t-ruby-vscode

Repository files navigation

T-Ruby

T-Ruby for VS Code & Cursor

Official Website   •   GitHub   •   VS Code Marketplace   •   Cursor Marketplace

T-Ruby License

VS Code
Extension Downloads

Cursor (Open VSX)
Extension Downloads


T-Ruby language support for VS Code and Cursor. Provides syntax highlighting, LSP-based code intelligence, and development tools for T-Ruby - a TypeScript-style static type system for Ruby.

Note: This extension shares the same source code for both VS Code and Cursor, providing identical functionality in both editors.

Requirements

gem install t-ruby

Installation

VS Code

Install from the Visual Studio Marketplace:

  1. Open VS Code
  2. Go to Extensions (Ctrl+Shift+X)
  3. Search for "T-Ruby"
  4. Click Install

Or install via command line:

code --install-extension t-ruby.t-ruby

Cursor

Install from the Open VSX Registry:

  1. Open Cursor
  2. Go to Extensions (Ctrl+Shift+X)
  3. Search for "T-Ruby"
  4. Click Install

Configuration

After installation, configure the extension in VS Code settings (Ctrl+,):

{
  "t-ruby.lspPath": "trc",
  "t-ruby.enableLSP": true,
  "t-ruby.diagnostics.enable": true,
  "t-ruby.completion.enable": true
}

Configuration Options

Option Type Default Description
t-ruby.lspPath string "trc" Path to T-Ruby compiler
t-ruby.enableLSP boolean true Enable Language Server
t-ruby.diagnostics.enable boolean true Enable real-time diagnostics
t-ruby.completion.enable boolean true Enable autocomplete

Features

Syntax Highlighting

The extension provides full syntax highlighting for:

  • .trb files (T-Ruby source files)
  • .d.trb files (T-Ruby declaration files)

Type annotations, interfaces, and type aliases are highlighted distinctly.

IntelliSense

  • Autocomplete: Type suggestions for parameters and return types
  • Hover: View type information by hovering over symbols
  • Go to Definition: Navigate to type/function definitions

Diagnostics

Real-time error checking for:

  • Unknown types
  • Duplicate definitions
  • Syntax errors

Commands

Access via Command Palette (Ctrl+Shift+P):

Command Description
T-Ruby: Compile Current File Compile the active .trb file
T-Ruby: Generate Declaration File Generate .d.trb from source
T-Ruby: Restart Language Server Restart the LSP server

Quick Start Example

  1. Create a new file hello.trb:
type UserId = String

interface User
  id: UserId
  name: String
  age: Integer
end

def greet(user: User): String
  "Hello, #{user.name}!"
end
  1. Save the file - you'll see syntax highlighting and real-time diagnostics

  2. Hover over types to see their definitions

  3. Use Ctrl+Space for autocomplete suggestions

Troubleshooting

LSP not starting

  1. Check if trc is installed: which trc
  2. Verify the path in settings: t-ruby.lspPath
  3. Check Output panel: View > Output > T-Ruby Language Server

No syntax highlighting

  1. Ensure file has .trb or .d.trb extension
  2. Check file association: View > Command Palette > "Change Language Mode"

Performance issues

  • Disable diagnostics for large files: "t-ruby.diagnostics.enable": false
  • Restart the language server: Command Palette > "T-Ruby: Restart Language Server"

Contributing

Issues and pull requests are welcome! https://github.com/type-ruby/t-ruby-vscode/issues

Related

License

BSD 2-Clause

About

T-Ruby extention for VSCode + Cursor Marketplace

Resources

License

Stars

Watchers

Forks

Packages

No packages published