This PR updates the `theme_importer` with support for parsing theme
files containing comments.
Up until now we've been manually removing comments from the VS Code
theme files.
Release Notes:
- N/A
This PR extends our support for parsing hex color codes to `Rgba` to
additionally support 3-value (`#rgb`) and 4-value (`#rgba`) formats.
See [here](https://developer.mozilla.org/en-US/docs/Web/CSS/hex-color)
for more details on these hex color variants.
Release Notes:
- N/A
This PR refines a number of styles in the default theme, as well as
updates the theme importer to support importing syntax styles from VS
Code themes.
Release Notes:
- N/A
This fix only required changing the `overrides` queries for JavaScript
and TSX. I've made the fix in both the `zed2` and `zed` crates.
Release Notes:
- Fixed an issue in JavaScript and TSX files, where the 'toggle
comments' command used the wrong comment syntax inside of JSX tags and
expressions within JSX.
When this feature is set the `themes` module won't be compiled.
This allows us to run the `theme_importer` even when the `themes` module
has compile errors in it.
Fixes
> the most annoying thing i'm running into right now is that when i'm
patching something inside node_modules, Zed tries to pretty-format it
according to my prettier config. this messes up the patch because it has
formatting changes now. i need the pretty formatting on save to be off
inside node_modules, that never makes sense
feedback from #influencers
Do note though, that language servers will still format any file inside
node_modules, but at least it's not prettier now.
VSCode seem to format the node_modules/** files via language servers
too, so that seems ok for now, and the rest could be fixed during
> "project diagnostics" (eslint) seem to be running inside node_modules,
e.g. i'm seeing 3182 "errors" in my project. that doesn't make sense and
probably wastes resources in addition to being annoying
feedback later.
Release Notes:
- Fixed prettier formatting files inside node_modules
This PR takes a different approach to input handling.
Rather than returning the optional input handler, focus handle pair from
the element trait, we instead allow you to register an input handler
imperatively on the window context with `WindowContext::handle_input`.
You pass a focus handle reference and any implementer of
`PlatformInputHandler`. There's an `ElementInputHandler<V>` that
implements `PlatformWindowHandler` so long as `V` implements
`InputHandler`.
Release Notes:
- N/A
[[PR Description]]
Adds documentation to ColorScaleSteps:
```rust
/// Returns the specified step in the [`ColorScale`].
#[inline]
pub fn step(&self, step: ColorScaleStep) -> Hsla {
// Steps are one-based, so we need convert to the zero-based vec index.
self.0[step.0 - 1]
}
/// `Step 1` - Used for main application backgrounds.
///
/// This step provides a neutral base for any overlaying components, ideal for applications' main backdrop or empty spaces such as canvas areas.
///
#[inline]
pub fn step_1(&self) -> Hsla {
self.step(ColorScaleStep::ONE)
}
/// `Step 2` - Used for both main application backgrounds and subtle component backgrounds.
///
/// Like `Step 1`, this step allows variations in background styles, from striped tables, sidebar backgrounds, to card backgrounds.
#[inline]
pub fn step_2(&self) -> Hsla {
self.step(ColorScaleStep::TWO)
}
/// `Step 3` - Used for UI component backgrounds in their normal states.
///
/// This step maintains accessibility by guaranteeing a contrast ratio of 4.5:1 with steps 11 and 12 for text. It could also suit hover states for transparent components.
#[inline]
pub fn step_3(&self) -> Hsla {
self.step(ColorScaleStep::THREE)
}
/// `Step 4` - Used for UI component backgrounds in their hover states.
///
/// Also suited for pressed or selected states of components with a transparent background.
#[inline]
pub fn step_4(&self) -> Hsla {
self.step(ColorScaleStep::FOUR)
}
/// `Step 5` - Used for UI component backgrounds in their pressed or selected states.
#[inline]
pub fn step_5(&self) -> Hsla {
self.step(ColorScaleStep::FIVE)
}
/// `Step 6` - Used for subtle borders on non-interactive components.
///
/// Its usage spans from sidebars' borders, headers' dividers, cards' outlines, to alerts' edges and separators.
#[inline]
pub fn step_6(&self) -> Hsla {
self.step(ColorScaleStep::SIX)
}
/// `Step 7` - Used for subtle borders on interactive components.
///
/// This step subtly delineates the boundary of elements users interact with.
#[inline]
pub fn step_7(&self) -> Hsla {
self.step(ColorScaleStep::SEVEN)
}
/// `Step 8` - Used for stronger borders on interactive components and focus rings.
///
/// It strengthens the visibility and accessibility of active elements and their focus states.
#[inline]
pub fn step_8(&self) -> Hsla {
self.step(ColorScaleStep::EIGHT)
}
/// `Step 9` - Used for solid backgrounds.
///
/// `Step 9` is the most saturated step, having the least mix of white or black.
///
/// Due to its high chroma, `Step 9` is versatile and particularly useful for semantic colors such as
/// error, warning, and success indicators.
#[inline]
pub fn step_9(&self) -> Hsla {
self.step(ColorScaleStep::NINE)
}
/// `Step 10` - Used for hovered or active solid backgrounds, particularly when `Step 9` is their normal state.
#[inline]
pub fn step_10(&self) -> Hsla {
self.step(ColorScaleStep::TEN)
}
/// `Step 11` - Used for text and icons requiring low contrast or less emphasis.
#[inline]
pub fn step_11(&self) -> Hsla {
self.step(ColorScaleStep::ELEVEN)
}
/// `Step 12` - Used for text and icons requiring high contrast or prominence.
#[inline]
pub fn step_12(&self) -> Hsla {
self.step(ColorScaleStep::TWELVE)
}
```
Release Notes:
- N/A
This PR switches us over to a fork of `ctor` that contains the fixes
from https://github.com/mmastrac/rust-ctor/pull/295, backported to our
current version of `ctor` (v0.1.20).
Once 1) the `ctor` maintainer publishes a new version with that change
and 2) we're ready to upgrade to the latest version of `ctor` we can
switch back to the mainline version.
Release Notes:
- N/A
This adds a `UniformList` element and partially implements `Picker` as a
component, using `UniformList`. Because editor2 isn't fully implemented
yet, the picker doesn't have filtering logic yet. We want to merge this
for now though, to make the UniformList element available for other
crates.
Release Notes:
- N/A
Project2's LLVM IR size is ~33-44% bigger than project1 due to the fact
that in gpui2 we call async_task::spawn(_local) with impl Future instead
of dyn Future, which leads to quite a few more instantiations of
RawTask.
LLVM-IR size for project2:
| build_type | main | this branch | project1 |
| debug | 2617795 | 2022814 | 1817866 |
| release | 4439033 | 3715086 | 3314489 |
Note that this PR is in line with what was done in GPUI1 (we've also
boxed futures there).
Release Notes:
- N/A
Project2's LLVM IR size is ~20-25% bigger than project1 due to the fact that in gpui2 we call async_task::spawn(_local) with impl Future instead of dyn Future, which leads to quite a few more instantiations of RawTask.
LLVM-IR size for project2:
| build_type | main | this branch | project1 |
| debug | 2617795 | 2022814 | 1817866 |
| release | 4439033 | 3715086 | 3314489 |
This PR reworks the way we define our third-party themes to make them
work as overlays on top of a base theme.
We introduce the concept of a `UserThemeFamily` that contains
`UserTheme`s. Rather than being an entire theme definition on their own,
a `UserTheme` just contains optional overrides for the values in a
`Theme`.
When resolving a `UserTheme`, we apply it on top of the base theme. Any
values not overridden in the `UserTheme` will fall back to the `Theme`
defaults.
Right now we are just using `UserTheme` to model third-party themes that
we distribute with the Zed binary. However, this same structure can also
be used to import arbitrary user themes (such as from a theme registry,
or even a theme blob from the settings file).
Release Notes:
- N/A
This PR renames the `ThemeVariant` type to `Theme`.
This better reflects its purpose, as well as matches the same name as we
had before, which should make porting crates slightly easier.
Release Notes:
- N/A
[[PR Description]]
Thanks @maxdeviant for all the help with this one 🫂
- Adds the `theme_importer` crate
- Adds the ability to import themes in VSCode Format.
- Adds the `assets/themes/src` folder with source files for imported
themes
- Adds an initial set of themes: `andromeda`, `ayu`, `dracula`,
`gruvbox`, `night-owl`, `noctis`, `palenight`, `rose-pine`, `solarized`,
`synthwave-84`.
From the README:
## Usage
- `cargo run -p theme_importer` - Import the context of
`assets/themes/src`
---
## Troubleshooting
As the importer generates rust files, you may need to manually do some
cleanup in `registry.rs` and `themes/mod.rs` if you remove themes or
delete the `themes` folder in the theme crate.
---
## Required Structure
To import a theme or series of themes 3 things are required:
- `family.json`: A JSON file containing the theme family metadata and
list of theme variants
- `{theme_name}.json`: One theme json for each theme variant
- `LICENSE`: A license file for the theme family
### `family.json`
#### `name`
The name of the theme family. Avoid special characters.
This will be used for the theme family directory name (lowercased) and
the theme family name in the Zed UI.
Good:
- `Rose Pine`
- `Synthwave 84`
- `Monokai Solarized`
Bad:
- `Rosé Pine`
- `Synthwave '84`
- `Monokai (Solarized)`
#### `author`
The author of the theme family. This can be a name or a username.
This will be used for the theme family author in the Zed UI.
#### `themes`
A list of theme variants.
`appearance` can be either `light` or `dark`. This will impact which
default fallback colors are used, and where the theme shows up in the
Zed UI.
### `{theme_name}.json`
Each theme added to the family must have a corresponding JSON file. This
JSON file can be obtained from the VSCode extensions folder (once you
have installed it.) This is usually located at `~/.vscode/extensions`
(on macOS).
You can use `open ~/.vscode/extensions` to open the folder in Finder
directly.
Copy that json file into the theme family directory and tidy up the
filenames as needed.
### `LICENSE`
A LICENSE file is required to import a theme family. Failing to provide
a complete text license will cause it to be skipped when the import is
run.
If the theme only provices a license code (e.g. MIT, Apache 2.0, etc.)
then put that code into the LICENSE file.
If no license is provided, either contact the theme creator or don't add
the theme.
---
### Complete Example:
An example family with multiple variants:
```json
{
"name": "Ayu",
// When both name and username are available
// prefer the `username (name)` format
"author": "dempfi (Ike Ku)",
"themes": [
{
"name": "Ayu Light",
"file_name": "ayu-light.json",
"appearance": "light"
},
{
"name": "Ayu Mirage",
"file_name": "ayu-mirage.json",
"appearance": "dark"
},
{
"name": "Ayu Dark",
"file_name": "ayu-dark.json",
"appearance": "dark"
}
]
}
```
An example single variant family:
```json
{
"name": "Andromeda",
"author": "Eliver Lara (EliverLara)",
"themes": [
{
"name": "Andromeda",
"file_name": "andromeda.json",
"appearance": "dark"
},
{
"name": "Andromeda Bordered",
"file_name": "andromeda-bordered.json",
"appearance": "dark"
}
]
}
```
Release Notes:
- N/A
- Make tab bar visible
- Fix tab text colors
- Ensure panes cover the available space
- Make the close button close
- Fix bug when unsubscribe called after remove
- WIP: start on editor element
- Add hover behaviour to tabs
- Add PointingHand on tabs
- gpui2: Add on_hover events
- Tooltip on tabs
- MOAR TOOLTIPS
- Use an `IconButton` for the tab close button
- Remove unneeded type qualification
- Tooltips in mouse event handler & fix executor timer
- Move more tooltip logic into gpui2 & fix tooltip moving on paint
- Update tooltip code a bit
- Allow multiple subscriptions from one entity handle
Release Notes:
- N/A
This PR applies a number of field renames in the `ThemeColors` struct
from the `import-theme` branch.
This will help prevent this branch from diverging too far from `main`.
Release Notes:
- N/A
---------
Co-authored-by: Nate Butler <iamnbutler@gmail.com>
Co-authored-by: Marshall Bowers <1486634+maxdeviant@users.noreply.github.com>
Follow-up of https://github.com/zed-industries/zed/pull/3225
That PR enabled every `project::Event::DiskBasedDiagnosticsFinished` to
update the diagnostics, which turned out to be bad, Zed does query for
more diagnostics after every excerpt update, and that seems to be due to
`Event::Edited` emitted by the multibuffers created in the diagnostics
panel.
* now, instead of eagerly updating the diagnostics every time, only do
that if the panel has 0 or 1 caret placed and no changes were made in
the panel yet.
Otherwise, use previous approach and register the updated paths to defer
their update later.
* on every `update_excerpts` in the diagnostics panel, query the entire
diagnostics summary (and store it for the future comparisons), compare
old and new summaries and re-query diagnostics for every path that's not
in both summaries.
Also, query every path that was registered during the
`DiskBasedDiagnosticsFinished` updates that were not eagerly updated
before.
This way we're supposed to get all new diagnostics (for new paths added)
and re-check all old paths that might have stale diagnostics now.
* do diagnostics rechecks concurrently for every path now, speeding the
overall process
Release Notes:
- Fixed diagnostics triggering too eagerly during multicaret edits and
certain stale diagnostics not being removed in time
This fixes a tiny UX bug where the tooltip would appear to move if you
hovered over an element, then moved your mouse out and back within
500ms.
The fix is to retain the task, so we can drop it to cancel it when the
mouse leaves.
Also changes the time we construct the tooltip to the time it first
shows.
This PR reorganizes the components in the `ui2` crate.
The distinction between "elements" and "components" is now gone, with
all of the reusable components living under `components/`.
The components that we built while prototyping but will eventually live
in other crates currently reside in the `to_extract/` module.
Release Notes:
- N/A
r-a now has 2 different types of diagnostics:
* "disk-based" ones that come from `cargo check` and related, that emit
`project::Event::DiskBasedDiagnosticsStarted` and
`DiskBasedDiagnosticsFinished`
* "flycheck" diagnostics from r-a itself, that it tries to dynamically
apply to every buffer open, that come with `DiagnosticsUpdated` event.
Latter diagnostics update frequently, on every file close and open, but
`diagnostics.rs` logic had never polled for new diagnostics after
registering the `DiagnosticsUpdated` event, so the only way we could
have newer diagnostics was to re-open the whole panel.
The PR fixes that, and also adds more debug logging to the module.
The logic of the fix looks very familiar to previous related fix:
https://github.com/zed-industries/zed/pull/3128
One notable thing after the fix: "flycheck" diagnostics stay forever if
the diagnostics panel is opened: excerpts in that panel do not allow the
buffer to get dropped (hence, closed in terms of r-a) and get the
updated, zero diagnostics.
If the diagnostics panel is opened and closed multiple times, those
errors gradually disappear.
Release Notes:
- Fixed diagnostics panel not refreshing its contents properly
This PR removes the `Default` impl for `ThemeColors`.
Since we need default light and dark variants for `ThemeColors`, we
can't use a single `Default` impl.
Release Notes:
- N/A