Self-Review Checklist:
- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable
Closes #ISSUE
Release Notes:
- N/A
Update the JSON schema generated for the settings file in order to be
able to provide the list of valid actions when editing the values for
the `command_aliases` setting.
While reviewing https://github.com/zed-industries/zed/pull/52892 , I
noticed that, even though we already have support for this in the keymap
file, we don't support it for the `command_aliases` setting, so went
ahead and refactored this a bit such that the existing functionality for
the keymap file JSON schema could also be re-used for the
`command_aliases` setting.
Here's a quick big-picture breakdown of the relevant changes:
* Add `settings_content::ActionName` newtype, representing a simple
named action without arguments. The
`settings_content::ActionName::build_schema` function can be used to
build the schema of all possible action names.
* Add `settings_content::ActionWithArguments` newtype, representing an
action with arguments. This was mostly done so as to keep both action
without arguments and action with arguments newtypes together,
even though we don't have
`settings_content::ActionWithArguments::build_schema`, as it is only
used by the keymap schema generation logic and probably doesn't warrant
moving it here right now.
* Update both
`settings_content::WorkspaceSettingsContent::command_aliases` and
`workspace::workspace_settings::WorkspaceSettings::command_aliases` to
now be of type `HashMap<String, ActionName>` such that, when the json
schema for `command_aliases` is generate, it'll now reference the
`#/$defs/ActionName` schema.
* Update `SettingsStore::json_schema` so as to populate the
`#/$defs/ActionName` schema at runtime, replacing it with the actual
list of valid action names.
Self-Review Checklist:
- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable
Release Notes:
- Added support for auto-completing action names on `command_aliases`
setting
This PR revamps our feature flag system, to enable richer iteration.
Feature flags can now:
- Support enum values, for richer configuration
- Be manually set via the settings file
- Be manually set via the settings UI
This PR also adds a feature flag to demonstrate this behavior, a
`agent-thread-worktree-label`, which controls which how the worktree tag
UI displays.
Self-Review Checklist:
- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable
Release Notes:
- N/A
(This should be merged after #48332)
This PR exposes the LSP settings schema functionality to extensions,
allowing them to provide JSON schema for `initialization_options` and
`settings` fields to enable autocomplete in settings files.
New extension API methods (v0.8.0+):
- `language_server_initialization_options_schema`
- `language_server_settings_schema`
Both methods return an optional JSON string conforming to JSON schema.
Older extension versions gracefully return `None`.
Release Notes:
- Added support for settings schemas for the next version of the
extension API so that settings autocompletion can be provided for
language server settings.
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: MrSubidubi <finn@zed.dev>
Closes#46556
## Summary
- Fix "Property `ty` is not allowed" warning in `settings.json` for LSP
adapters registered via `register_available_lsp_adapter()`
- Add `available_lsp_adapter_names()` method to include these adapters
in schema generation
- Support `initialization_options` schema lookup for available adapters
## Problem
LSP adapters registered via `register_available_lsp_adapter()` were not
included in the settings JSON schema. This caused validation warnings
like:
Property ty is not allowed
Even though `ty` is a built-in Python language server that works
correctly.
**Affected adapters:**
- `ty`, `py`, `python-lsp-server`
- `eslint`, `vtsls`, `typescript-language-server`
- `tailwindcss-language-server`, `tailwindcss-intellisense-css`
## Solution
Schema generation now queries both:
1. `all_lsp_adapters()` - adapters bound to specific languages
2. `available_lsp_adapter_names()` - adapters enabled via settings (new)
Related: #43104, #45928
Release Notes:
- Fixed an issue where not all LSP adapters would be suggested for
completion, or recognized as valid in `settings.json`
---------
Co-authored-by: Ben Kunkle <ben@zed.dev>
This extends the LSP settings schema system to also provide autocomplete
for the `settings` field (used for `workspace/configuration` responses),
in addition to the existing `initialization_options` support (#).
Changes:
- Add `settings_schema` method to `LspAdapter` trait and
`CachedLspAdapter`
- Update schema URL paths to be more explicit:
- `lsp/{adapter}/initialization_options` for init options schema
- `lsp/{adapter}/settings` for settings schema
- Add schema resolution logic for the new settings path
- Update tests to verify both schema references
Release Notes:
- Added autocomplete support for the `settings` field in LSP
configuration, complementing the existing `initialization_options`
autocomplete.
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Introduces a separate JSON schema for project settings that excludes
user-only settings like `auto_update`, `telemetry`, `vim_mode`, etc.
This provides more accurate autocomplete and validation when editing
`.zed/settings.json`.
- Add `SettingsStore::project_json_schema`
- Map `.zed/settings.json` to `zed://schemas/project_settings` schema URL
Release Notes:
- Improved autocomplete for the project settings file
(`.zed/settings.json`) to only include settings that are valid at the
project level, excluding user-only settings.
Release Notes:
- N/A
Avoids iterating through all registered actions when looking up a single
action's schema in json_schema_store.
---------
Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
Dynamic schemas (settings, settings/lsp/*, debug_tasks) are now cached
after first generation and returned immediately via Task::ready() on
subsequent requests.
Cache is invalidated when `notify_schema_changed()` is called, which
happens when:
- Extensions are installed/uninstalled (affects settings schema)
- DAP registry changes (affects debug_tasks schema)
This eliminates repeated foreground thread blocking for the same dynamic
schema.
**Note:** This PR is based on #46823 and should be merged after it.
Release Notes:
- N/A
---------
Co-authored-by: Ben Kunkle <ben@zed.dev>
Static schemas (tasks, snippets, jsonc, keymap, action/*, tsconfig,
package_json, inspector_style) are now computed once on first access
using LazyLock and returned immediately via Task::ready().
These schemas never change at runtime because:
- tasks, snippets, jsonc, inspector_style are derived from static Rust
types
- tsconfig, package_json are bundled JSON files (include_str!)
- keymap and action/* depend only on registered actions, which are
collected at compile/link time via the inventory crate (extensions
cannot add actions)
This eliminates foreground thread blocking for these schema requests.
**New functions added to KeymapFile:**
- `generate_json_schema_from_inventory()`: generates keymap schema
without App context
- `get_action_schema_by_name()`: looks up single action schema without
App context
Release Notes:
- N/A
---------
Co-authored-by: Ben Kunkle <ben@zed.dev>
This makes this take the LSP adapter delegate instead of the binary
itself.
Despite us passing `LanguageServerBinaryOptions` with `allow_download:
false`, extensions would still try to download the binary because it was
never implemented for these to respect that. This would cause us to try
to download all langauge servers provided by extensions when opening a
settings file and/or requesting the JSON schema for that.
This PR fixes this by passing the LSP adapter delegate instead, so the
few language servers which actually want to have the binary for
resolving the initialization options can decide on this by themselves.
With that, we no longer download all language servers for the schema
request
Release Notes:
- N/A
There are some too long lines which make `rustfmt` unable to format the
file, which in turn makes editing and working with this file rather
hard. This PR fixes this.
Release Notes:
- N/A
Closes#18287
Release Notes:
- Added autocomplete for lsp initialization_options
## Description
This MR adds the following code-changes:
- `initialization_options_schema` to the `LspAdapter` to get JSON
Schema's from the language server
- Adds a post-processing step to inject schema request paths into the
settings schema in `SettingsStore::json_schema`
- Adds an implementation for fetching the schema for rust-analyzer which
fetches it from the binary it is provided with
- Similarly for ruff
<img width="857" height="836" alt="image"
src="https://github.com/user-attachments/assets/3cc10883-364f-4f04-b3b9-3c3881f64252"
/>
## Open Questions(Would be nice to get some advice here)
- Binary Fetching:
- I'm pretty sure the binary fetching is suboptimal. The main problem
here was getting access to the delegate but i figured that out
eventually in a way that i _hope_ should be fine.
- The toolchain and binary options can differ from what the user has
configured potentially leading to mismatches in the autocomplete values
returned(these are probably rarely changed though). I could not really
find a way to fetch these in this context so the provided ones are for
now just `default` values.
- For the trait API it is just provided a binary, since i wanted to use
the potentially cached binary from the CachedLspAdapter. Is that fine
our should the arguments be passed to the LspAdapter such that it can
potentially download the LSP?
- As for those LSPs with JSON schema files in their repositories i can
add the files to zed manually e.g. in
languages/language/initialization_options_schema.json, which could cause
mismatches with the actual binary. Is there a preferred approach for Zed
here also with regards to updating them?
Follow-up of https://github.com/zed-industries/zed/pull/43854
Closes https://github.com/zed-industries/zed/issues/40970
Seems that json language server does not distinguish between JSONC and
JSON files in runtime, but there is a static schema, which accepts globs
in its `fileMatch` fields.
Use all glob overrides and file suffixes for JSONC inside those match
fields, and provide a grammar for such matches, which accepts trailing
commas.
Release Notes:
- Improved JSONC trailing comma handling
Release Notes:
- N/A
According to
[microsoft/vscode#254689](https://github.com/microsoft/vscode/issues/254689),
the json.schemastore.org domain has been deprecated and should now use
www.schemastore.org (or schemastore.org) instead.
This PR updates all occurrences of the old domain within the Zed
codebase,
including code, documentation, and configuration files.
We've been considering removing workspace-hack for a couple reasons:
- Lukas ran into a situation where its build script seemed to be causing
spurious rebuilds. This seems more likely to be a cargo bug than an
issue with workspace-hack itself (given that it has an empty build
script), but we don't necessarily want to take the time to hunt that
down right now.
- Marshall mentioned hakari interacts poorly with automated crate
updates (in our case provided by rennovate) because you'd need to have
`cargo hakari generate && cargo hakari manage-deps` after their changes
and we prefer to not have actions that make commits.
Currently removing workspace-hack causes our workspace to grow from
~1700 to ~2000 crates being built (depending on platform), which is
mainly a problem when you're building the whole workspace or running
tests across the the normal and remote binaries (which is where
feature-unification nets us the most sharing). It doesn't impact
incremental times noticeably when you're just iterating on `-p zed`, and
we'll hopefully get these savings back in the future when
rust-lang/cargo#14774 (which re-implements the functionality of hakari)
is finished.
Release Notes:
- N/A
Closes #ISSUE
Improves the efficiency of our interactions with the Zed language
server. Previously, on startup and after every workspace configuration
changed notification, we would send >1MB of JSON Schemas to the JSON
LSP. The only reason this had to happen was due to the case where an
extension was installed that would result in a change to the JSON schema
for settings (i.e. added language, theme, etc).
This PR changes the behavior to use the URI LSP extensions of
`vscode-json-language-server` in order to send the server URI's that it
can then use to fetch the schemas as needed (i.e. the settings schema is
only generated and sent when `settings.json` is opened. This brings the
JSON we send to on startup and after every workspace configuration
changed notification down to a couple of KB.
Additionally, using another LSP extension request we can notify the
server when a schema has changed using the URI as a key, so we no longer
have to send a workspace configuration changed notification, and the
schema contents will only be re-requested and regenerated if the schema
is in use.
Release Notes:
- Improved the efficiency of communication with the builtin JSON LSP.
JSON Schemas are no longer sent to the JSON language server in their
full form. If you wish to view a builtin JSON schema in the language
server info tab of the language server logs (`dev: open language server
logs`), you must now use the `editor: open url` action with your cursor
over the URL that is sent to the server.
- Made it so that Zed urls (`zed://...`) are resolved locally when
opened within the editor instead of being resolved through the OS. Users
who could not previously open `zed://*` URLs in the editor can now do so
by pasting the link into a buffer and using the `editor: open url`
action (please open an issue if this is the case for you!).
---------
Co-authored-by: Michael <michael@zed.dev>