Improve JavaScript and TypeScript syntax highlighting (#25328)
Release Notes: - Improved JavaScript and TypeScript syntax highlighting. | Zed 0.174.6 | With this PR | | --- | --- | |  |  | - `regex_flags`: `keyword.regex`, see the [Regex PR](https://github.com/zed-industries/zed/pull/25332) for other Regex scopes - `@`: `punctuation.special`, as in Python - `jsx_text`: `text.jsx` - `=`: `operator` -> `punctuation.jsx.delimiter`, `punctuation` as in [VS Code](0fe195613e/extensions/html/syntaxes/html.tmLanguage.json (L78)
) and [Atom](ee750a014a/grammars/tree-sitter-html.cson (L47)
) - added `jsx` scope to target JSX tokens specifically ```javascript /** * @keyword comment */ @log class X { render() { return ( <div jsx_attribute="value"> <Input onKeyPress={super.bind(this)}/> jsx_text </div> ); } } const IDENTIFIER = true ``` --------- Co-authored-by: Marshall Bowers <git@maxdeviant.com>
This commit is contained in:
parent
3e75a661dd
commit
8f40bcc86c
3 changed files with 27 additions and 14 deletions
|
@ -82,6 +82,7 @@
|
|||
(escape_sequence) @string.escape
|
||||
|
||||
(regex) @string.regex
|
||||
(regex_flags) @keyword.regex
|
||||
(number) @number
|
||||
|
||||
; Tokens
|
||||
|
@ -210,6 +211,8 @@
|
|||
"<" @punctuation.bracket
|
||||
">" @punctuation.bracket)
|
||||
|
||||
(decorator "@" @punctuation.special)
|
||||
|
||||
; Keywords
|
||||
|
||||
[ "abstract"
|
||||
|
@ -229,11 +232,13 @@
|
|||
] @keyword
|
||||
|
||||
; JSX elements
|
||||
(jsx_opening_element (identifier) @tag (#match? @tag "^[a-z][^.]*$"))
|
||||
(jsx_closing_element (identifier) @tag (#match? @tag "^[a-z][^.]*$"))
|
||||
(jsx_self_closing_element (identifier) @tag (#match? @tag "^[a-z][^.]*$"))
|
||||
(jsx_opening_element (identifier) @tag.jsx (#match? @tag.jsx "^[a-z][^.]*$"))
|
||||
(jsx_closing_element (identifier) @tag.jsx (#match? @tag.jsx "^[a-z][^.]*$"))
|
||||
(jsx_self_closing_element (identifier) @tag.jsx (#match? @tag.jsx "^[a-z][^.]*$"))
|
||||
|
||||
(jsx_attribute (property_identifier) @attribute)
|
||||
(jsx_opening_element (["<" ">"]) @punctuation.bracket)
|
||||
(jsx_closing_element (["</" ">"]) @punctuation.bracket)
|
||||
(jsx_self_closing_element (["<" "/>"]) @punctuation.bracket)
|
||||
(jsx_attribute (property_identifier) @attribute.jsx)
|
||||
(jsx_opening_element (["<" ">"]) @punctuation.bracket.jsx)
|
||||
(jsx_closing_element (["</" ">"]) @punctuation.bracket.jsx)
|
||||
(jsx_self_closing_element (["<" "/>"]) @punctuation.bracket.jsx)
|
||||
(jsx_attribute "=" @punctuation.delimiter.jsx)
|
||||
(jsx_text) @text.jsx
|
||||
|
|
|
@ -86,6 +86,7 @@
|
|||
(escape_sequence) @string.escape
|
||||
|
||||
(regex) @string.regex
|
||||
(regex_flags) @keyword.regex
|
||||
(number) @number
|
||||
|
||||
; Tokens
|
||||
|
@ -221,6 +222,8 @@
|
|||
"<" @punctuation.bracket
|
||||
">" @punctuation.bracket)
|
||||
|
||||
(decorator "@" @punctuation.special)
|
||||
|
||||
; Keywords
|
||||
|
||||
[ "abstract"
|
||||
|
@ -240,11 +243,13 @@
|
|||
] @keyword
|
||||
|
||||
; JSX elements
|
||||
(jsx_opening_element (identifier) @tag (#match? @tag "^[a-z][^.]*$"))
|
||||
(jsx_closing_element (identifier) @tag (#match? @tag "^[a-z][^.]*$"))
|
||||
(jsx_self_closing_element (identifier) @tag (#match? @tag "^[a-z][^.]*$"))
|
||||
(jsx_opening_element (identifier) @tag.jsx (#match? @tag.jsx "^[a-z][^.]*$"))
|
||||
(jsx_closing_element (identifier) @tag.jsx (#match? @tag.jsx "^[a-z][^.]*$"))
|
||||
(jsx_self_closing_element (identifier) @tag.jsx (#match? @tag.jsx "^[a-z][^.]*$"))
|
||||
|
||||
(jsx_attribute (property_identifier) @attribute)
|
||||
(jsx_opening_element (["<" ">"]) @punctuation.bracket)
|
||||
(jsx_closing_element (["</" ">"]) @punctuation.bracket)
|
||||
(jsx_self_closing_element (["<" "/>"]) @punctuation.bracket)
|
||||
(jsx_attribute (property_identifier) @attribute.jsx)
|
||||
(jsx_opening_element (["<" ">"]) @punctuation.bracket.jsx)
|
||||
(jsx_closing_element (["</" ">"]) @punctuation.bracket.jsx)
|
||||
(jsx_self_closing_element (["<" "/>"]) @punctuation.bracket.jsx)
|
||||
(jsx_attribute "=" @punctuation.delimiter.jsx)
|
||||
(jsx_text) @text.jsx
|
||||
|
|
|
@ -110,6 +110,7 @@
|
|||
(escape_sequence) @string.escape
|
||||
|
||||
(regex) @string.regex
|
||||
(regex_flags) @keyword.regex
|
||||
(number) @number
|
||||
|
||||
; Tokens
|
||||
|
@ -199,6 +200,8 @@
|
|||
"<" @punctuation.bracket
|
||||
">" @punctuation.bracket)
|
||||
|
||||
(decorator "@" @punctuation.special)
|
||||
|
||||
; Keywords
|
||||
|
||||
[
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue