Skip to main content

LSP SDK

The LSP SDK provides target-aware Language Server Protocol integration. Unlike traditional LSP setups that configure paths globally, RBS resolves dependencies per-target — your editor’s autocomplete, go-to-definition, and diagnostics reflect only the dependencies your specific target can actually import.

Why target-aware LSP?

Traditional LSP setups give you completions for every package installed on your system. RBS does it differently:

How it works

  1. You open a file — e.g., src/main.py in your editor.
  2. RBS resolves the target — determines that src/main.py belongs to //src:app.
  3. Dependencies are analyzed//src:app declares deps = ["@pip//requests", "@pip//flask", ":utils"].
  4. Paths are resolved — dependencies map to filesystem paths in .rbs/external-deps/.
  5. LSP is configured — the language server receives only the relevant paths.
  6. You get accurate completions — autocomplete suggests requests and flask, but not unrelated packages.

Quick start

1. Load a built-in provider

In your WORKSPACE.rbs:

2. Sync dependencies

3. Connect your editor

Your editor connects to the LSP through the RBS server automatically when you open files. If you’re building a custom integration, connect via:
  • WebSocket: ws://your-server/ws/lsp/{language}
  • REST API: http://your-server/api/lsp/*

Built-in providers

Python

  • Server: python-lsp-server (pylsp)
  • Extensions: .py, .pyi
  • Features: Jedi-based completion, rope refactoring, pyflakes linting

TypeScript / JavaScript

  • Server: typescript-language-server
  • Extensions: .ts, .tsx, .js, .jsx, .mjs, .cjs
  • Features: Full TypeScript/JavaScript support with type checking

Go

  • Server: gopls
  • Extensions: .go
  • Features: Official Go language server with full LSP support

Creating custom LSP providers

The SDK-first design means you can define LSP support for any language through configuration:

Parameters

Server references

The server parameter supports multiple formats:

Path resolution function

The resolve_paths function receives a context object with access to the target’s build graph:

Initialization options

Use ${RESOLVED_PATHS} as a placeholder that will be replaced with the resolved dependency paths:

REST API

List providers

Get a provider

List running servers

Start / stop a server

Resolve a file to its target

Find which target a file belongs to and what dependency paths are resolved:

WebSocket protocol

Connect

On connection:

Open a file (triggers path resolution)

Response:

LSP requests/responses

Standard JSON-RPC 2.0 LSP messages are proxied through the WebSocket:

Editor SDK integration


Troubleshooting

No completions

  1. Run rbs sync //your:target to ensure dependencies are downloaded.
  2. Verify the file belongs to a target with declared deps.
  3. Check that paths are resolved: POST /api/lsp/resolve with your file path.

LSP server not starting

Missing dependencies