chbk
|
1ae3d25aed
|
Improve Markdown highlighting (#37669)
Release Notes:
- Improved Markdown syntax highlighting
PR #25330 raised concerns about breaking changes, so I split it into two
PRs:
- This PR improves highlighting without deprecating existing selectors.
- PR #37670 is based on this PR and introduces new Markdown selectors.
| Zed 0.202.7 | With this PR |
| --- | --- |
| <img width="800" height="1080" alt="md-0 202 7"
src="https://github.com/user-attachments/assets/0b0b5920-32ed-454f-bc3b-bf5cd0a9086a"
/> | <img width="800" height="1080" alt="md-pr"
src="https://github.com/user-attachments/assets/a5923a2e-391e-4e09-a60b-1a142f9378f3"
/> |
Changes to include the `markup` selector, conforming to
[Neovim](https://github.com/nvim-treesitter/nvim-treesitter/blob/38e46a6d7ade5c8718f77b2b9fd98a0f7ab32c1e/queries/markdown/highlights.scm#L59),
[VS
Code](https://github.com/microsoft/vscode/blob/dfad570d15959a6ce7210a313a1190e76e8fe2e2/extensions/markdown-basics/syntaxes/markdown.tmLanguage.json#L60),
[Atom](https://github.com/atom/language-gfm/blob/6686ac6ccca2632af24d5c200f85bcd80b9fa752/grammars/gfm.json#L147),
and [Zed
itself](https://github.com/zed-industries/zed/blob/1e255e41ccfdb88e2266469f1ccfe0d41533280b/crates/languages/src/gitcommit/highlights.scm#L1).
- `paragraph`, `indented_code_block`, `pipe_table`: `text`
- `# Heading`: `title` -> `title.markup`
- `-`, `1.`, `>`, `|`: `punctuation.markup`
- ```` ``` ````: `punctuation.embedded.markup`
- `[1]: url.com`, `[link](url.com)`: `link_text.markup`
- `url.com`: `link_uri` -> `link_uri.markup`
- `*italic*`: `emphasis` -> `emphasis.markup`
- `**bold**`: `emphasis.strong` -> `emphasis.strong.markup`
- ``` `raw` ```: `text.literal` -> `text.literal.markup`
- `~~strikethrough~~`: `strikethrough.markup`
````md
# Heading
Some stylized text:
- `raw`
- *italic*
- ~strike~
- **strong**
> quoted
```python
print("some code")
```
1. Here is an 
2. A [link](https://github.com/zed-industries)
3. And even a [referenced link][1]
[1]: https://zed.dev
| tables | are |
| --- | --- |
| properly | scoped |
````
|
2025-09-09 13:05:07 -06:00 |
|
chbk
|
f522823988
|
Highlight shorthand fields in Rust (#37674)
Release Notes:
- Highlight shorthand fields in Rust
| Zed 0.202.7 | With this PR |
| --- | --- |
| <img width="370" height="50" alt="rust-0 202 7"
src="https://github.com/user-attachments/assets/856a4d82-3ad0-4248-ad51-0472a0b6531a"
/> | <img width="370" height="50" alt="rust-pr"
src="https://github.com/user-attachments/assets/25b8e357-8519-4533-9026-3f2874b42ddb"
/> |
|
2025-09-08 12:32:08 +03:00 |
|
chbk
|
a6a111cadd
|
Highlight labels in Go (#37673)
Release Notes:
- Highlight labels in Go
| Zed 0.202.7 | With this PR |
| --- | --- |
| <img width="160" height="50" alt="go-0 202 7"
src="https://github.com/user-attachments/assets/1a1b3b3c-52ae-41e3-a52b-c2a9bb7589d2"
/> | <img width="160" height="50" alt="go-pr"
src="https://github.com/user-attachments/assets/29020b9f-ed03-4298-aa5b-0201a81fd5e6"
/> |
|
2025-09-06 01:36:36 +02:00 |
|
chbk
|
9e5f89dc26
|
Improve CSS syntax highlighting (#25326)
Release Notes:
- Improved CSS syntax highlighting
| Zed 0.174.6 | With this PR |
| --- | --- |
| 
|

|
- `|`: `operator`
- `and`, `or`, `not`, `only`: `operator` -> `keyword.operator`, as
defined in other languages
- `id_name`, `class_name`: `property`/`attribute` -> `selector`, not a
property name. [CSS
reference](https://www.w3.org/TR/selectors-3/#class-html)
- `namespace_name`: `property` -> `namespace`, not a property name
- `property_name`: `constant` -> `property`, like `feature_name` already
defined
- `(keyword_query)`: `property`, similar to `feature_name`. [CSS
reference](https://www.w3.org/TR/mediaqueries-3/#media1)
- `keyword_query`: `constant.builtin`, [CSS
reference](https://www.w3.org/TR/mediaqueries-3/#media0)
- `plain_value`, `keyframes_name`: `constant.builtin`, [CSS
reference](https://www.w3.org/TR/css-values-3/#value-defs)
- `unit`: `type` -> `type.unit`,
[Atom](https://github.com/atom/language-css/blob/9e4afce058b4593edf03ed1dec6033b163c678f0/grammars/tree-sitter-css.cson#L73)
and [VS
Code](https://github.com/microsoft/vscode/blob/336801752dd09afa76f5429fba846e533bcdb7d9/extensions/css/syntaxes/css.tmLanguage.json#L1393)
also have a `unit` scope for this. [CSS
reference](https://www.w3.org/TR/css3-values/#dimensions)
```css
@media (keyword_query) and keyword_query {}
@supports (feature_name: plain_value) {}
@namespace namespace_name url("string");
namespace_name|tag_name {}
@keyframes keyframes_name {
to {
top: 200unit;
color: #c01045;
}
}
tag_name::before,
#id_name:nth-child(even),
.class_name[attribute_name=plain_value] {
property_name: 2em 1.2em;
--variable: rgb(250, 0, 0);
color: var(--variable);
animation: keyframes_name 5s plain_value;
}
```
|
2025-06-06 17:14:32 -04:00 |
|
chbk
|
3da1de2a48
|
Add JSDoc scope (#29476)
This is a small PR that adds a `.jsdoc` scope to JSDoc tokens, just like
[JSX](https://github.com/zed-industries/zed/blob/3fdbc3090d2cc5c2e24014009cccbe5e7c55d217/crates/languages/src/javascript/highlights.scm#L239)
has a specific scope.
This effectively allows differentiating between JavaScript keywords and
JSDoc tags in comments.
Release Notes:
- Add scope for JSDoc
|
2025-06-06 08:31:59 -04:00 |
|
chbk
|
7f868a2eff
|
Improve Rust macro highlighting (#28182)
Release Notes:
- Improved Rust macro highlighting
| Zed 0.180.2 | With this PR |
| --- | --- |
|

|

|
```rust
macro_rules! square {
($e:expr) => { $e * $e };
}
```
- `$var`: `variable`
- `expr`: `type`
|
2025-05-05 23:50:57 +03:00 |
|
chbk
|
bf9e5b4f76
|
Fix Python builtin type highlighting (#29475)
| Zed 0.183.11 | With this PR |
| --- | --- |
|

|

|
```python
class A:
@classmethod
def list(cls, list: list) -> list:
return list
A.list(list())
A.list(list=list())
A.list(list=list(A.list(list())))
list: list = list()
A.list(list)
A.list(list=list)
A.list(list=A.list(list))
```
Release Notes:
- Improved Python builtin type highlighting
|
2025-04-28 11:34:55 -04:00 |
|
chbk
|
f97546b6ef
|
Improve Regex highlighting (#28183)
| Zed 0.180.2 | With this PR |
| --- | --- |
|

|

|
```js
match = "424242"
regex = /(42)+?\d{2}\1/g
```
- `/`: `operator` -> `string.regex` (like `"` for regex strings)
- `+?`: `operator.regex`
- `\d`: `string.escape` -> `string.escape.regex`
- `\1`: `keyword.operator.regex` (backreference)
- `/g`: `keyword.regex` -> `keyword.operator.regex`
- `{2}`: `number` -> `number.quantifier.regex`
Release Notes:
- Improved Regex highlighting
|
2025-04-18 12:44:13 -04:00 |
|
chbk
|
e4f692ac75
|
html: Improve syntax highlighting (#28184)
| Zed 0.180.2 | With this PR |
| --- | --- |
|

|

|
```html
<script>
return <div class="main content"></div>
</script>
<div class="main content"></div>
<span></spn>
```
Changes homogenize JSX and HTML
- `"`: `string`
- `=`: `operator` -> `punctuation.delimiter` like in
[JSX](https://github.com/zed-industries/zed/blob/3775496b84cfc9ebf27376119742f3484d4997f2/crates/languages/src/javascript/highlights.scm#L246),
[VSCode](https://github.com/microsoft/vscode/blob/336801752dd09afa76f5429fba846e533bcdb7d9/extensions/html/syntaxes/html.tmLanguage.json#L382)
- `erroneous_end_tag_name`: `keyword` -> not a keyword
Release Notes:
- Improved HTML highlighting
|
2025-04-17 13:40:56 -04:00 |
|
chbk
|
0708d476ca
|
Improve Bash heredoc highlighting (#28185)
Release Notes:
- Improved Bash heredoc highlighting
| Zed 0.180.2 | With this PR |
| --- | --- |
|

|

|
```bash
cat << EOT >> hello.txt
hello world
EOT
```
- `<<`: `operator`
- `EOT`: `string`
|
2025-04-06 11:14:05 -04:00 |
|
 chbkandJoão Marcos
|
f4d1e7901c
|
Improve Regex syntax highlighting (#25332)
Release Notes:
- Improved Regex syntax highlighting
| Zed 0.174.6 | With this PR |
| --- | --- |
|

|

|
- `(?P=`, `<`: `punctuation.bracket`
- `group_name`: `property` -> `label`
- `^`, `$`: `string.escape` -> `operator`
- `\b`, `\B`, `\k`: `string.escape` -> `keyword.operator`
- added `regex` scope to target regex tokens specifically
```js
regex = /^(?<group>[!\.\?])\b[a-z]+word\k<group>$/g
```
---------
Co-authored-by: João Marcos <marcospb19@hotmail.com>
|
2025-03-22 16:11:19 -03:00 |
|
 chbkandMarshall Bowers
|
8f40bcc86c
|
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](https://github.com/microsoft/vscode/blob/0fe195613ed9901f669cd0f799fe807f0189d029/extensions/html/syntaxes/html.tmLanguage.json#L78)
and
[Atom](https://github.com/atom/language-html/blob/ee750a014a003c3d6f10b91e3cd5f9bfa0f051e6/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>
|
2025-02-21 21:54:16 +00:00 |
|
 chbkandMarshall Bowers
|
3e75a661dd
|
Improve Rust syntax highlighting (#25333)
Release Notes:
- Improved Rust syntax highlighting.
| Zed 0.174.6 | With this PR |
| --- | --- |
|

|

|
- `identifier`: `variable`
```rust
let identifier = true;
const IDENTIFIER: i32 = 3;
```
---------
Co-authored-by: Marshall Bowers <git@maxdeviant.com>
|
2025-02-21 16:20:53 -05:00 |
|
 chbkandMarshall Bowers
|
59a153b2e1
|
Improve Python syntax highlighting (#25331)
Release Notes:
- Improved Python syntax highlighting.
| Zed 0.174.6 | With this PR |
| --- | --- |
|

|

|
- `identifier`: `variable`
- `.`, `,`, `:`: `punctuation.delimiter`
- `@`: `operator`, for matrix multiplication
```python
class Mat(list):
def __matmul__(self, b):
...
a, b = Mat(), Mat()
identifier = a @ b
IDENTIFIER = True
```
---------
Co-authored-by: Marshall Bowers <git@maxdeviant.com>
|
2025-02-21 20:52:04 +00:00 |
|
 chbkandMarshall Bowers
|
144d8a1db6
|
Improve C and C++ syntax highlighting (#25325)
Release Notes:
- Improved C and C++ syntax highlighting.
| Zed 0.174.6 | With this PR |
| --- | --- |
|

|

|
- `NULL`, `nullptr`: `constant` -> `constant.builtin`
```cpp
#include <stdbool.h>
int a[] = {true, false};
const int * IDENTIFIER = nullptr;
```
---------
Co-authored-by: Marshall Bowers <git@maxdeviant.com>
|
2025-02-21 12:01:39 -05:00 |
|
 chbkandMarshall Bowers
|
7deceb62dc
|
Improve Go syntax highlighting (#25327)
Release Notes:
- Improved Go syntax highlighting.
| Zed 0.174.6 | With this PR |
| --- | --- |
|

|

|
- `package_identifier`: `namespace`, language-agnostic scope for
modules, packages, namespaces
- `method_elem`: `function.method`
- `;` ,`.` ,`,` ,`:`: `punctuation.delimiter`
```go
package my_package
import (
pkg "fmt"
)
type A interface {
method_elem(foo int, bar float64) int
}
func main() {
identifier := true
const constant int = 3
for i := 0; i <= 3; i++ {
pkg.Println(identifier)
}
}
```
---------
Co-authored-by: Marshall Bowers <git@maxdeviant.com>
|
2025-02-21 11:32:14 -05:00 |
|
chbk
|
5e4bdbbcde
|
Improve JSON syntax highlighting (#25329)
Release Notes:
- Improved JSON syntax highlighting.
| Zed 0.174.6 | With this PR |
| --- | --- |
|

|

|
- `null`: `constant` -> `constant.builtin`
- `,`, `:`: `punctuation.delimiter`
```json
{
"property": null,
"boolean": true
}
```
|
2025-02-21 15:59:32 +00:00 |
|
chbk
|
d0a0303428
|
Improve Bash syntax highlighting (#25324)
Release Notes:
- Improved Bash syntax highlighting
| Zed 0.174.6 | With this PR |
| --- | --- |
|

|

|
- `string`: `string`
- `variable`: `property` -> `variable`
- `number`: `number`
- `regex`: `string.regex`
- `>&`, `>&-`, `:`, `//`, `/`, `%`, `%%`, `#`, `##`, `=`, `==`:
`operator`
- `-lt`, `-le`, `-gt`, `-ge`, `-eq`, `-ne`, `-z`, `-n`:
`keyword.operator`
- `;`: `punctuation.delimiter`
- `(`, `)`, `{`, `}`, `[`, `]`: `punctuation.bracket`
- `$`, `${ }`, `$( )`: `punctuation.special`, as defined in other
languages
```bash
variable=I\ like\ Zed
function my_function() {
echo "Hello world, ${variable//regex/string}" > file
}
if [ $(uid) -lt 600 ]; then
my_function;
cat file | grep hello >&3
fi
```
|
2025-02-21 10:36:07 -05:00 |
|
chbk
|
2f416aebbe
|
Add syntax scopes to themes (#25323)
Release Notes:
- Added syntax scopes to themes
Supports:
- [Improve CSS syntax
highlighting](https://github.com/zed-industries/zed/pull/25326)
- [Improve Go syntax
highlighting](https://github.com/zed-industries/zed/pull/25327)
- [Improve Markdown syntax
highlighting](https://github.com/zed-industries/zed/pull/25330)
Changes:
- Adds highlighting rules for the following new scopes, using theme
colors:
- `heading`
- `namespace`
- `selector`
- `strikethrough`
- `unit`
- Renames scopes that are no longer used in `zed/crates/languages/src`
or `zed/extensions` to their new names:
- `punctuation.list_marker` -> `punctuation.markup`
- `link_text` -> `link`
- `link_uri` -> `link.url`, as defined in the [gitcommit
grammar](https://github.com/zed-industries/zed/blob/dff47a843695d03160680502e6d94634e376698e/crates/languages/src/gitcommit/highlights.scm#L5)
- `text.literal` -> `raw`
|
2025-02-21 09:21:18 -05:00 |
|