Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
languages/html-razor/highlights.scm uses nonstandard capture names (@punctuation.*.html) that are inconsistent with the repo’s other queries and may not be themed correctly in Zed.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
This PR adds a Razor language definition to the C# Zed extension so .razor (Blazor components) and .cshtml (ASP.NET Razor Pages/MVC views) get syntax highlighting and basic editor behaviors, while leaving existing C# / project-file behavior unchanged.
Changes:
- Registers a new
Razorlanguage for.razorand.cshtml, including syntax highlighting, bracket matching, and indentation rules. - Adds a hidden
html-razorlanguage used for markup highlighting/injection so Razor expressions inside quoted attribute values don’t break string coloring. - Pins tree-sitter grammars for
razorand a forkedhtml_razorinextension.toml.
File summaries
| File | Description |
|---|---|
| README.md | Updates extension description to mention Razor highlighting. |
| extension.toml | Adds grammar pins for razor and html_razor. |
| languages/razor/config.toml | Registers the Razor language and file suffixes. |
| languages/razor/highlights.scm | Adds Razor + inlined C# highlighting queries and overrides. |
| languages/razor/injections.scm | Injects markup regions into html-razor for consistent HTML/CSS/JS highlighting. |
| languages/razor/indents.scm | Defines indentation behavior for braces/brackets/parentheses. |
| languages/razor/brackets.scm | Defines bracket matching pairs for Razor buffers. |
| languages/html-razor/config.toml | Adds hidden html-razor language used only for injections. |
| languages/html-razor/highlights.scm | Provides markup highlighting used by injected html-razor layers. |
| languages/html-razor/injections.scm | Injects CSS/JS inside <style>/<script> and common attribute contexts. |
Review details
Suppressed comments (1)
languages/html-razor/highlights.scm:25
html-razoruses@punctuation.bracket.htmlfor tag delimiters; other query files in this repo use standard captures like@punctuation.bracket/@punctuation.delimiterwithout language suffixes. Using the standard capture improves theme compatibility and keeps punctuation coloring consistent.
[
"<"
">"
"<!"
"</"
"/>"
] @punctuation.bracket.html
- Files reviewed: 10/12 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| (entity) @string.special | ||
|
|
||
| "=" @punctuation.delimiter.html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds Razor syntax highlighting for Blazor components (
.razor) and ASP.NET Core Razor Pages / MVC views (.cshtml), following the guidance in zed-industries/extensions#7567 to bring this into the C# extension.Fixes #41.
What's included
Razorlanguage (languages/razor/) registered for.razorand.cshtml, with highlighting for directives, implicit/explicit expressions, control-flow blocks, and C# code blocks; plus bracket matching, auto-indentation, andrazorcode fences.extension.toml:razor→ Meeksoft/tree-sitter-razor @97ce5a5— fork of tris203/tree-sitter-razor @d4664e4(current main), adding parsing of Razor expressions inside quoted HTML attribute values and queryable attribute names.html_razor→ Meeksoft/tree-sitter-html @bb3ca3e— fork of tree-sitter/tree-sitter-html @bfa075d(the revision Zed's html extension pins), whose quoted attribute values may contain Razor expressions.html-razorlanguage (languages/html-razor/, ~50 lines of queries) instead of plainhtml, so values likedata-date="@x.ToString("o")"keep their string colors instead of terminating at the first inner quote. CSS in<style>and JS in<script>still highlight through the standard injection chain.Scope
Editing support only. No language server is attached to Razor buffers, and
.cs,.csproj, and.slnxbehavior is unchanged.Screenshots
Dashboard.cshtml+ProductCatalog.razorin VS Code Dark Modern:The same files in Ayu Mirage:
Verification
Installed as a dev extension and verified:
.cs,.csproj,.slnxhighlighting and language servers unchanged.razor/.cshtmlrecognized asRazor; directives, expressions, and control flow highlighted<style>/<script>work