Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Zed C#

A [C#](https://learn.microsoft.com/en-us/dotnet/csharp/) extension for [Zed](https://zed.dev).
A [C#](https://learn.microsoft.com/en-us/dotnet/csharp/) extension for [Zed](https://zed.dev), with syntax highlighting for Razor (`.razor`, `.cshtml`).

## Development

Expand Down
Binary file added assets/razor-syntax-ayu-mirage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/razor-syntax-vscode-dark-modern.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions extension.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,11 @@ commit = "485f0bae0274ac9114797fc10db6f7034e4086e3"
repository = "https://github.com/tree-sitter-grammars/tree-sitter-xml"
commit = "863dbc381f44f6c136a399e684383b977bb2beaa"
path = "xml"

[grammars.razor]
repository = "https://github.com/Meeksoft/tree-sitter-razor"
commit = "97ce5a575798a7737b53a2bf2745ab8bd73c792d"

[grammars.html_razor]
repository = "https://github.com/Meeksoft/tree-sitter-html"
commit = "bb3ca3e7b0bb79079030fe9af9c1175bcd099839"
4 changes: 4 additions & 0 deletions languages/html-razor/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name = "html-razor"
grammar = "html_razor"
hidden = true
block_comment = ["<!-- ", " -->"]
25 changes: 25 additions & 0 deletions languages/html-razor/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
(tag_name) @tag

(doctype) @tag.doctype

(attribute_name) @attribute

[
"\""
"'"
(attribute_value)
] @string

(comment) @comment

(entity) @string.special

"=" @punctuation.delimiter.html

[
"<"
">"
"<!"
"</"
"/>"
] @punctuation.bracket.html
24 changes: 24 additions & 0 deletions languages/html-razor/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
((comment) @injection.content
(#set! injection.language "comment"))

(script_element
(raw_text) @injection.content
(#set! injection.language "javascript"))

(style_element
(raw_text) @injection.content
(#set! injection.language "css"))

(attribute
(attribute_name) @_attribute_name
(#match? @_attribute_name "^style$")
(quoted_attribute_value
(attribute_value) @injection.content)
(#set! injection.language "css"))

(attribute
(attribute_name) @_attribute_name
(#match? @_attribute_name "^on[a-z]+$")
(quoted_attribute_value
(attribute_value) @injection.content)
(#set! injection.language "javascript"))
14 changes: 14 additions & 0 deletions languages/razor/brackets.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
("(" @open
")" @close)

("[" @open
"]" @close)

("{" @open
"}" @close)

("<" @open
">" @close)

("\"" @open
"\"" @close)
7 changes: 7 additions & 0 deletions languages/razor/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name = "Razor"
code_fence_block_name = "razor"
grammar = "razor"
path_suffixes = ["razor", "cshtml"]
block_comment = ["<!-- ", " -->"]
word_characters = ["@"]
tab_size = 4
Loading