Velaguides

Editor setup

Install the VS Code extension, see what the language server does, and connect it to any other editor.

Vela ships a language server, vela-rbxts-lsp, and a VS Code extension that runs it. The server uses the same compiler as your build, so what the editor says about a class is what the build does.

VS Code

Install Vela Roblox IntelliSense from the marketplace. It needs VS Code ^1.91.0.

Terminal window
code --install-extension astra-void.vela-rbxts-lsp

Open a .tsx or .ts file and the server starts. There is nothing to enable per project.

Settings

A change to a velaRbxts.lsp.* setting restarts the server for you. The others apply at once.

PropTypeDescription
velaRbxts.lsp.serverPathstringPath to a server binary. A relative path is resolved against the workspace root. Defaults to "", meaning auto-resolve.
velaRbxts.lsp.trace.server"off" | "messages" | "verbose"LSP protocol trace written to the extension's output channel. Defaults to "off".
velaRbxts.lsp.enabledbooleanWhether to start the server at all. Defaults to true.
velaRbxts.inlayHints.enabledbooleanShow what each class lowers to as an inlay hint after the class. Defaults to false.
velaRbxts.classFunctionsstring[]Helpers whose arguments are class lists wherever they are called, such as ["cn", "cva"]. Defaults to [].
velaRbxts.lintRecord<string, "error" | "warning" | "info" | "hint" | "ignore">A level per diagnostic code, replacing the default one. Defaults to {}.
velaRbxts.validatebooleanWhether to show Vela diagnostics. Completions, hover and colors keep working when it's off. Defaults to true.

To quiet one check or make another fail loudly, set its code. Every diagnostic shows its code:

.vscode/settings.json
{
"velaRbxts.lint": {
"overridden-class": "ignore",
"unknown-theme-key": "error"
}
}

Commands

Run these from the command palette:

  • Vela: Restart Language Server restarts the server and re-reads every vela.config, without reloading the window.
  • Vela: Show Output opens the server’s output channel.
  • Vela: Sort Classes sorts the classes in the active file.

How the server binary is resolved

If velaRbxts.lsp.serverPath is set, the extension runs that binary. Otherwise it runs the server bundled for your platform.

The bundled platforms are darwin arm64 and x64, linux x64 gnu and musl, linux arm64 gnu, and win32 x64. There is no cargo run fallback, so set serverPath when you work on the server itself.

When your config fails to load

If the extension can’t load your vela.config.ts, it shows a notification naming the file and the reason. Fix the file and save. The notification clears once the config loads. Until then the editor uses the default theme, so your custom keys show as unknown.

What the language server provides

  • Completions inside a className, triggered by -, :, ", ' and space. A completion replaces only the segment under the cursor. Some scales list only common values. For example, opacity-* suggests round numbers, but any integer from 0 to 100 compiles.
  • Hover shows what a class resolves to. Scaled offsets read in rem first, such as 1rem (16px at the base viewport). If your config pins rem, hovers use plain pixels.
  • Diagnostics as you type. While you’re still typing a real key, unknown-theme-key waits: bg-sla stays quiet on the way to bg-slate-800, but bg-nope warns at once.
  • Color swatches in the gutter, editable with the editor’s color picker.
  • Quickfixes for Vela diagnostics: up to three suggested replacements, plus “remove token”.
  • Document highlight for other uses of the token under the cursor.
  • Inlay hints, off by default. Turn on velaRbxts.inlayHints.enabled to see them:
<frame className="p-4 rounded-l-lg" />
// ↑ UIPadding.PaddingTop/Right/Bottom/Left
// ↑ UICorner.TopLeftRadius, BottomLeftRadius

All of these work anywhere a class string can appear in a className. That includes a function (how Vide writes a dynamic class), template interpolations, as const, satisfies, string concatenation, and object keys and spreads.

They also work on a const string that a className names, at the place it’s declared:

const base = "px-4 bg-slate-700"; // completed, checked and sorted here
<frame className={cn(base, active && "p-2")} />

The editor reads the same consts the compiler lowers. A let, a const declared after the class value, or one inside another function isn’t read.

A helper called outside a className, such as a cva recipe at the top of the file, is read only once you list it in velaRbxts.classFunctions:

// with "velaRbxts.classFunctions": ["cva", "tw"]
const button = cva("px-4 rounded-md", {
variants: { size: { sm: "text-sm", lg: "text-lg" } },
});
const card = tw`p-4 bg-slate-800`;

In an object, a key counts as a class list only when its value is a condition, as in clsx. In a cva-style map, defaultVariants and the variant names in compoundVariants are skipped.

The server does not provide go-to-definition, references, rename, formatting, semantic tokens or signature help. Your editor uses its TypeScript service for those.

On a component like <Panel />, the editor can’t know which element it renders. It offers every utility there and never raises unsupported-host-utility.

Overridden classes

The editor warns when a later class overrides an earlier one. In bg-red-500 bg-blue-500, the first class has no effect, so it gets an overridden-class warning naming the winner. It’s drawn faded, and the quickfix removes it. A repeat like p-4 p-4 reports "p-4" is repeated later.

The check uses the compiler’s own resolver, so it always agrees with the build:

  • px-2 p-4 warns on px-2. p-4 px-2 stays quiet, because px-2 only overrides part of p-4.
  • w-4 h-8 and font-mono font-bold combine into one property and stay quiet.
  • bg-red-500/50 bg-blue-500 warns on bg-red-500/50. The solid color also replaces the /50.
  • opacity-50 opacity-75 and divide-y divide-red-500/50 divide-blue-500 warn too.
  • A bg-* before a gradient warns and names the gradient. A gradient forces BackgroundColor3 to white.

Only classes under the same condition are compared. bg-red-500 hover:bg-blue-500 and md:px-6 max-md:px-3 never warn. md:hover: and hover:md: count as the same condition.

This is an editor-only lint. Builds never report it.

Arbitrary values with a named class

An arbitrary value that lowers exactly like a named class gets a canonical-class note at info level, and the quickfix swaps in the name:

<frame className="w-[16px] h-[100%]" />
// ↑ w-4 ↑ h-full

The named class follows your theme, so a later change to the scale reaches it. Your own theme’s steps count: if your spacing scale names card as 18 pixels, px-[18px] points at px-card. Variants are kept, so hover:w-[16px] points at hover:w-4.

Sorting class names

The source action source.sortVelaClasses puts every className in the file into a standard order: layout, sizing, spacing, colors, radius, typography, then classes with variant prefixes.

before
<frame className="text-lg bg-blue-600 flex p-4 hover:bg-blue-700 rounded-lg w-full" />
after
<frame className="flex w-full p-4 bg-blue-600 rounded-lg text-lg hover:bg-blue-700" />

Sorting never changes what your classes do:

  • Classes that can set the same Roblox property keep their order. A px-4 after p-2 stays after it.
  • Variant chains sort by the conditions they name. hover:md:bg-red-500 md:hover:bg-blue-500 keeps its order because both name the same two conditions.
  • A longer chain sorts after the shorter one it extends, so dark:hover: stays behind dark:. group-* and peer-* sort between focus: and dark:.

It doesn’t change your layout either. Whitespace and line breaks stay as written, and so does the whitespace around template interpolations. A class with a space inside brackets, such as w-[calc(100% - 4px)], moves as one class. A class whose bracket never closes is left alone.

Run it with Vela: Sort Classes, from the source-action menu, or on save:

.vscode/settings.json
{
"editor.codeActionsOnSave": {
"source.sortVelaClasses": "explicit"
}
}

To check the order in CI, run vela sort --check. Any LSP client that supports source actions can request the sort by that kind. The same sort is available as sortClassNames on @vela-rbxts/compiler. It takes { source, fileName } and returns { edits: [{ range: { start, end }, text }] }.

Other editors

The server speaks LSP over stdio and doesn’t depend on VS Code. Add it to your project:

pnpm add -D @vela-rbxts/lsp

Then set your editor’s server command to:

Terminal window
npx --package @vela-rbxts/lsp vela-rbxts-lsp

Keep --package. The binary is vela-rbxts-lsp, but the npm package is @vela-rbxts/lsp. A bare npx vela-rbxts-lsp finds nothing, because that name belongs to the VS Code extension.

Text sync is incremental and positions are UTF-16. The server exits on the exit notification even if the client keeps stdin open.

Pass your config to the server

The server never reads vela.config.ts itself. Your editor has to evaluate the config and send the result in initializationOptions:

initializationOptions
{
"workspaceRoot": "/abs/path/to/project",
"configs": [
{ "dir": "/abs/path/to/project", "json": "{\"theme\":{\"colors\":{ }}}" }
]
}

Each entry is a directory plus that directory’s resolved config as a JSON string. A file uses the config of its nearest containing dir, which is how per-package configs in a monorepo work.

To update configs after startup, send the custom method vela-rbxts/setConfigs with only configs in the payload.

The VS Code extension does exactly this. It finds every vela.config.ts, vela.config.json and vela.css, evaluates each directory’s config through @vela-rbxts/rbxtsc-host/project-config, and sends { dir, json } pairs at startup. It sends them again when any of those files or any .css file changes, so stylesheets pulled in with @import are followed too.

Your client can build the JSON any way it likes. It only has to match the resolved TailwindConfig shape.

The VS Code settings classFunctions, lint and validate go in initializationOptions too, with the same names and values. To change them later, send workspace/didChangeConfiguration with them under velaRbxts. The server re-checks open files when lint or validate changes. A level it doesn’t know is dropped, and the rest of the settings still apply.

Platform packages

The vela-rbxts-lsp launcher picks one of six platform packages, installed as optional dependencies:

  • @vela-rbxts/lsp-darwin-arm64
  • @vela-rbxts/lsp-darwin-x64
  • @vela-rbxts/lsp-linux-arm64-gnu
  • @vela-rbxts/lsp-linux-x64-gnu
  • @vela-rbxts/lsp-linux-x64-musl
  • @vela-rbxts/lsp-win32-x64-msvc

The launcher also looks for @vela-rbxts/lsp-linux-arm64-musl and @vela-rbxts/lsp-win32-arm64-msvc, but neither is published. On those platforms, build from source.

See also

  • Configuration: the config shape the server expects.
  • Diagnostics: every code the editor can show, and which also appear in a build.
  • Dynamic class names: the case the editor can’t help with, because nothing is reported.