
# Rojo Integration

rbxdev-ls supports Rojo projects and `sourcemap.json` files for cross-file module resolution. When your workspace has a Rojo project or sourcemap, the language server maps filesystem paths to the Roblox data model, enabling `require()` resolution across files.

## Rojo projects

If your workspace root contains a `default.project.json`, the server reads the project tree and builds a module index from it. This lets completions and go-to-definition work across module boundaries.

No configuration is needed. The server detects the project file automatically on startup.

## sourcemap.json

As an alternative to a full Rojo project, you can provide a `sourcemap.json` generated by:

```bash
rojo sourcemap --output sourcemap.json --include-non-scripts
```

The server watches this file for changes and reloads the module index automatically when it updates. This is useful if you run `rojo sourcemap` as a file watcher during development.

## How require resolution works

When you write:

```lua
local Module = require(game.ReplicatedStorage.Shared.Utils)
```

The server:

1. Parses the `require()` path into segments: `["ReplicatedStorage", "Shared", "Utils"]`
2. Walks the Rojo tree to find the matching filesystem path
3. Reads the target file's exports (functions, tables, types)
4. Provides completions and type information for the imported module

## Module exports

The server extracts exports from modules by parsing the return statement:

```lua
-- Utils.luau
local Utils = {}

Utils.formatNumber = function(n: number): string
    return string.format("%d", n)
end

return Utils
```

After `require`, completions show `formatNumber` with its parameter types and return type.
