TSRX
TSRX language support with LSP and Tree-sitter syntax highlighting for Ripple, React, Preact, Solid, Vue, Octane, and additional compiler targets.
How to install
With Forge Super installed, the button above opens the app on this extension, where you press Install. Nothing is installed until you do.
You can also open the Extensions panel in the app and search for TSRX. The extension's id is tsrx.
Don't have Forge Super yet? Download it here.
README
From the extension's repository, written by its authors and not by Mentenaz. See the source.
TSRX Extension for Zed
This extension provides TSRX language support for the
Zed editor. It provides syntax and language-server support for
.tsrx files across Ripple, React, Preact, Solid, Vue, Octane, and third-party
compiler targets.
Installation
From the Zed Extension Marketplace
The TSRX extension is available in the Zed Extension Marketplace:
- Open Zed
- Press
Cmd/Ctrl + Shift + Xto open extensions - Search for "TSRX"
- Click "Install"
Development Installation
-
Clone this repository
-
Install Rust with the WebAssembly target used by Zed:
rustup target add wasm32-wasip2 -
From the repository root, stage the extension outside the working tree:
pnpm zed:stage-dev -
Open Zed and run zed: install dev extension from the command palette
-
Select the staging directory printed by the command
Do not select packages/zed-plugin directly. Zed writes its Cargo output,
compiled WebAssembly, and a checkout of the configured grammar repository into the
selected extension directory. Staging keeps those generated files out of this
repository.
After changing the extension source, run pnpm zed:stage-dev again and then run
zed: rebuild dev extension in Zed. Once Zed is using the staged directory,
remove artifacts left by an older direct installation with:
pnpm zed:clean-worktree
Set TSRX_ZED_DEV_DIR to override the platform-specific cache directory used for
staging.
Language Server Setup
The extension looks for the language server @tsrx/language-server in this order:
-
The local project that you have opened in Zed via the
package.jsonand looks fornode_modules/.bin/tsrx-language-server. So make sure to install your dependencies first via:npm install -
Globally installed:
npm install -g @tsrx/language-server # or pnpm add -g @tsrx/language-server -
The extension automatically downloads the TSRX language server the first time it runs. The version is pinned via the
configentry for@tsrx/language-serverin this package'spackage.json.
Project-local installations (node_modules/.bin/tsrx-language-server) are also
detected automatically.
Formatting
The TSRX language server formats .tsrx files with your project's Prettier and
@tsrx/prettier-plugin (see
Formatting).
Install both in the project:
npm install -D prettier @tsrx/prettier-plugin
# or
pnpm add -D prettier @tsrx/prettier-plugin
Zed's default formatter setting (auto) uses the language server for .tsrx
files.
Closing tags
When you type the > that ends an opening tag, the TSRX language server inserts
the closing tag: <div> becomes <div></div>, with the cursor between the tags.
Zed asks the server for it through on-type formatting, which is on by default. Use
Zed 1.17 or newer: older versions move the cursor past the closing tag.
To turn closing tags off, turn on-type formatting off for .tsrx files in Zed's
settings:
{
"languages": {
"TSRX": { "use_on_type_format": false },
},
}
TypeScript backends
The TSRX language server hosts TypeScript itself (the classic backend), so
.tsrx files get their TypeScript features from it. Zed's own TypeScript support
runs vtsls or typescript-language-server, both TypeScript 5 based, and cannot
serve .tsrx files.
Which TypeScript the language server uses
In the default setup, @tsrx/language-server runs TypeScript itself and looks for
it as described here. With TypeScript 7 it does not: the server runs with
--typescript-backend=native, loads no TypeScript and searches for none, and
TypeScript 7's own language server (tsc --lsp) provides the TypeScript features.
Zed has no TypeScript 7 language server for .tsrx files yet; see the native
backend below.
@tsrx/language-server uses the project's typescript: node_modules/typescript
in the folder you open in Zed, or in a parent folder. Without one, it uses a
typescript installed next to the server. It does not install one itself, so
install typescript in the project:
npm install -D typescript
# or
pnpm add -D typescript
Any version below 7 works. When the server finds no typescript, or finds
TypeScript 7, it still starts and Zed shows a warning that says what it found.
.tsrx files then get no type checking, hover or completions. TSRX compile
errors, CSS in <style>, the outline, formatting and closing tags still work.
To use another TypeScript, set its lib folder in Zed's settings:
{
"lsp": {
"tsrx-language-server": {
"initialization_options": {
"typescript": { "tsdk": "/path/to/typescript/lib" },
},
},
},
}
What goes in tsconfig.json
- TypeScript 5.9 or 6 (classic backend): install
@tsrx/typescript-pluginand add{ "name": "@tsrx/typescript-plugin" }tocompilerOptions.plugins. Zed'svtslsortypescript-language-serverloads the plugin from there, next to the workspacetypescriptpackage it runs, so.tsfiles that import.tsrxmodules resolve them. The TSRX language server needs nothing: it serves the.tsrxfiles themselves. - TypeScript 7 (native backend): declare
@tsrx/content-mapperundercontentMappersinstead; TypeScript 7 ignoresplugins. Both entries can sit in one tsconfig, since TypeScript 5 and 6 ignorecontentMappers. - VS Code alone needs no
pluginsentry: its extension hands the plugin to VS Code's own tsserver.
TypeScript 7 support for .tsrx files is not complete yet. The gaps and the
upstream TypeScript issues behind them are tracked in
tsrx-org/tsrx#136; if you run into
one that is not listed there, please file a new issue.
The server also has a native backend that leaves TypeScript features to
TypeScript 7's language server (tsc --lsp) through @tsrx/content-mapper (see
@tsrx/language-server).
It only makes sense next to a client that runs TypeScript 7 with
initializationOptions.runExternalCode: true for .tsrx files. Zed has no such
language server yet, so keep the default classic backend in Zed. Once Zed can
run TypeScript 7 for .tsrx files, select the backend without an extension update
through Zed's settings:
{
"lsp": {
"tsrx-language-server": {
"initialization_options": { "typescriptBackend": "native" },
},
},
}