Skip to content

rx-language-server: semantic tokens tell sources from equations - #9

Draft
oddcelot wants to merge 1 commit into
mainfrom
rx-semantic-tokens
Draft

oddcelot wants to merge 1 commit into
mainfrom
rx-semantic-tokens

Conversation

@oddcelot

@oddcelot oddcelot commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

In the projection, sources and equations are both consts. So TypeScript's semantic tokens mark both as a variable with readonly. Zed with semantic_tokens: "combined" draws those tokens over the grammar's colours. State and derived values then look the same, even though the grammar told them apart.

This adds two modifiers to the legend, source and equation. A variable gets one when its declaration is initialised with the projection's __.typed/__.src or __.eq, following imports to find the declaration. The work is in the new src/tokens.js; bin/server.js only registers it.

#4 is the Zed side that colours the two modifiers. VS Code doesn't use them yet.

node test/run.js passes (23/23). The new cases run on examples/shop/cart.rx:

  • the declaration and a read of a source, and of an equation
  • a source imported from catalog.rx
  • a write's target
  • a handler's local, which gets neither modifier

…hich equations

In the projection a source and an equation are both a const, so TypeScript's
tokens call both `variable` with `readonly`. An editor that draws semantic
tokens over its grammar's colours (Zed with semantic_tokens "combined") then
shows state and derived values alike, where the grammar told them apart.

The legend has two modifiers more, `source` and `equation`. A variable token
gets one when its declaration, followed through an import, is initialised with
the projection's __.typed/__.src or __.eq.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant