Skip to content

Add semantic token rules for C# (Roslyn) token types#92

Open
tatsudo wants to merge 1 commit into
zed-extensions:mainfrom
tatsudo:roslyn-semantic-token-rules
Open

Add semantic token rules for C# (Roslyn) token types#92
tatsudo wants to merge 1 commit into
zed-extensions:mainfrom
tatsudo:roslyn-semantic-token-rules

Conversation

@tatsudo

@tatsudo tatsudo commented Jun 28, 2026

Copy link
Copy Markdown

Roslyn reports an extended semantic-token legend (field, controlKeyword, recordClass, extensionMethod, ...) beyond the standard LSP types. Without rules for them, those tokens are dropped and C# falls back to tree-sitter-only highlighting (e.g. a private field looks like a local variable).

This adds languages/csharp/semantic_token_rules.json mapping the C#-specific types to theme styles. Standard types stay covered by Zed's built-in defaults, so only the Roslyn-specific ones are listed here (same approach the built-in rust/cpp/go/python rules use).

Fixes #85. Moved here from zed-industries/zed#60027 per @MrSubidubi's suggestion. Needs zed-industries/zed#60015 (dynamic registration of textDocument/semanticTokens) to actually deliver the tokens — together they resolve #85.

Showcase

Click to view showcase

Before — Roslyn's C# token types aren't mapped, so fields/keywords fall back to tree-sitter (a field looks like a plain variable):

Screenshot 2026-06-28 at 10 06 41

After — fields, constants, control-flow keywords and records get semantic colors:

Screenshot 2026-06-28 at 09 58 15

Roslyn reports an extended token-type legend (field, controlKeyword,
recordClass, extensionMethod, ...) beyond the standard LSP set. Without
matching rules these tokens are dropped and fall back to tree-sitter-only
highlighting. Map the C#-specific types to theme styles; standard types are
still covered by Zed's built-in defaults.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@cla-bot cla-bot Bot added the cla-signed label Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Record names considered variables

1 participant