GitHub - engneer-hamachan/ruby-ti

3 min read Original article ↗

Ruby-TI

Static type checking for MRuby. No annotations required.

Go Version License


Ruby-TI is a static type analyzer for MRuby that performs type inference and checking on your Ruby code without requiring type annotations. Write Ruby naturally and get real-time type feedback in your editor.

The power of static typing. The freedom of Ruby.

Ruby-TI Demo

Features

  • Zero-annotation type inference - No need to write type signatures. Ruby-TI analyzes your code automatically
  • Real-time feedback - Get instant type checking as you code through LSP integration
  • Customizable type system - Define types that match your mruby environment
  • Editor integration - Works with Neovim, VSCode, and any LSP-compatible editor
  • MRuby focused - Built with embedded Ruby environments in mind

Requirements

  • Go 1.24.5+ for building from source
  • Neovim or VSCode (or any LSP-compatible editor)

Quick Start

Install Ruby-TI:

git clone https://github.com/engneer-hamachan/ruby-ti.git
cd ruby-ti
make install

# Add to PATH (fish example):
set -x PATH "/path/to/ruby-ti/bin:$PATH"

Install LSP Server:

git clone https://github.com/engneer-hamachan/ruby-ti-lsp.git
cd ruby-ti-lsp
make install

# Add to PATH (fish example):
set -x PATH "/path/to/ruby-ti-lsp/bin:$PATH"

Setup your project:

cd your-ruby-project
cp -r /path/to/ruby-ti/.ti-config .

Configure your editor - See Editor Setup for detailed configuration.

That's it! Open a Ruby file and start coding with type checking enabled.

Editor Setup

Neovim (coc.nvim)

Add to your coc-settings.json:

{
  "languageserver": {
    "ruby-ti": {
      "command": "ti-lsp",
      "filetypes": ["ruby", "json"]
    }
  }
}
VSCode

Install the extension:

code --install-extension /path/to/ruby-ti-lsp/vscode/ruby-ti-lsp-0.1.0.vsix
Other Editors

Configure your LSP client to run ti-lsp for Ruby files. The server follows standard LSP protocols.

Screenshots

Diagnostics - Real-time type error detection

Type diagnostics

Hover Information - Inspect types on hover

Hover type information

Auto-completion - Intelligent code suggestions

Auto-completion

Code Actions - Quick fixes and refactoring

Code actions

Inline Documentation - View method documentation directly in editor

Inline documentation

External File Loading - Analyze types across multiple files

External file loading - Definition

External file loading - Usage

Configuration

Supported Classes

Ruby-TI is expanding support with a focus on PicoRuby and embedded environments:

Array · Bool · Class · Enumerable · Float · GPIO · Hash · Integer · Kernel · Math · Nil · Object · Proc · Range · String · Symbol

More classes and PicoRuby features are being added continuously.

Customization

The .ti-config directory contains type definitions that you can customize for your specific mruby environment. Edit the JSON files to define types that make sense for your workflow.

See the Configuration Guide for detailed customization options.

Documentation

Contributing

Issues and feedback are especially welcome! While the project is in active development and pull requests may be challenging to integrate, we'd love to hear about bugs, feature requests, and your experience using Ruby-TI.

License

MIT License - see LICENSE for details