Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve CSS syntax highlighting #25326

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

chbk
Copy link
Contributor

@chbk chbk commented Feb 21, 2025

Release Notes:

  • Improved CSS syntax highlighting
Zed 0.174.6 With this PR
css_0 174 6 css_pr
  • |: operator
  • and, or, not, only: operator -> keyword.operator, as defined in other languages
  • id_name, class_name: property -> selector, not a property name. CSS reference
  • 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
  • keyword_query: constant.builtin, CSS reference
  • plain_value, keyframes_name: constant.builtin, CSS reference
  • unit: type -> type.unit, Atom and VS Code also have a unit scope for this. CSS reference
@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;
}

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Feb 21, 2025
@chbk chbk marked this pull request as ready for review February 21, 2025 13:32
iamnbutler pushed a commit that referenced this pull request Feb 21, 2025
Release Notes:

  - Added syntax scopes to themes

Supports:

- [Improve CSS syntax
highlighting](#25326)
- [Improve Go syntax
highlighting](#25327)
- [Improve Markdown syntax
highlighting](#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`
@maxdeviant maxdeviant self-assigned this Feb 21, 2025
@chbk chbk marked this pull request as draft February 21, 2025 18:03
@chbk chbk force-pushed the syntax-css branch 2 times, most recently from 5bc2f67 to 45b8b80 Compare February 21, 2025 21:47
@chbk chbk marked this pull request as ready for review February 21, 2025 21:58
@chbk chbk marked this pull request as draft February 22, 2025 01:27
@chbk chbk marked this pull request as ready for review February 22, 2025 02:15
@chbk chbk force-pushed the syntax-css branch 2 times, most recently from 74ed13e to 3e9e5b5 Compare February 23, 2025 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants