Luau Language Server
An implementation of a language server for the Luau programming language.
Install the extension from the marketplace: https://marketplace.visualstudio.com/items?itemName=JohnnyMorganz.luau-lsp
The extension will automatically populate the latest API types and documentation.
To resolve your instance tree and provide module resolution, the language server uses Rojo sourcemaps. The language server will automatically create a
sourcemap.json in your workspace root on startup and whenever files are added/created/renamed.
It does this by running the
rojo sourcemap command, hence Rojo 7.1.0+ must be available to execute in your workspace root. It is recommend to
sourcemap.json file. In future, the language server will generate the file internally.
By default we generate a sourcemap for a
default.project.json project file. The name can be changed in extension settings, as well as whether non-script instances are included in the sourcemap (included by default). Autogeneration of sourcemaps can also be toggled completely on/off in settings - the server will instead just listen to manual changes to
The initial goal is to develop a language server supporting all common LSP functions. Module resolution and typing will initially revolve around Rojo.
The idea is to ensure module resolution is customisable, allowing the server to later be easily extended to support other environments where Luau may be used. We could also potentially take it a step forward, allowing the server to be used on an Lua 5.1 codebase through a translation layer (such as type comments through EmmyLua), allowing the language server to support general purpose Lua development powered by the Luau type inference engine.
If you use Luau in a different environment and are interested in using the language server, please get in touch!
- Rojo Files Resolution
- API Type Definitions
- Diagnostics (incl. type errors)
- Signature Help
- Go To Definition
- Go To Type Definition
- Find References
- Document Highlight
- Document Link
- Document Symbol
- Color Provider
- Folding Range
- Selection Range
- Call Hierarchy
- Type Hierarchy
- Semantic Tokens
- Inlay Hints
- Workspace Symbols
The following are extra features defined in the LSP specification, but most likely do not apply to Luau or are not necessary. They can be investigated at a later time:
- Go To Declaration (do not apply)
- Go To Implementation (do not apply)
- Code Actions (not necessary - could potentially add "fixers" for lints)
- Code Lens (not necessary)
- Inline Value (applies for debuggers only)
- Formatting (see stylua)
Build From Source
mkdir build && cd build cmake .. -DCMAKE_BUILD_TYPE=Release cmake --build . --target luau-lsp --config Release