Thanks for taking a look at this. I think this is a small but worthwhile refinement to Zed's existing Rust SQL syntax injection behaviour. **Before screenshot** <img width="1509" height="992" alt="202606072151kst-before" src="https://github.com/user-attachments/assets/37247d48-51cf-47c7-8a34-07c821869d0d" /> **After screenshot** <img width="1648" height="1196" alt="202606072159kst-after" src="https://github.com/user-attachments/assets/c10de0fc-3a30-4750-8f70-a050d74d4150" /> The main rationale is that Zed already recognises `sql!` as an explicit Rust SQL injection marker. This PR does not introduce a new broad heuristic, infer SQL from arbitrary Rust strings, or add framework-specific matching. It narrows the existing `sql!` behaviour so literal forms inject only the Rust `string_content` as SQL, rather than the whole macro payload. That distinction matters for real Rust SQL authoring. The current broad payload capture can work for simple token-tree examples like: ```rust sql!(SELECT * FROM carts); ``` but practical embedded SQL is often written as a normal string or raw string, especially for PostgreSQL queries with single-quoted values, multiline statements, dollar parameters, comments, and other syntax: ```rust sql!( r#" SELECT * FROM carts WHERE status IN ('open', 'checkout_started') "# ); ``` For those literal forms, treating Rust delimiters such as `"`, `r#"`, or `"#` as part of the SQL layer makes the injected SQL range less precise. This PR fixes that by injecting the literal body only, whilst preserving the historical unquoted token-tree form. The practical benefit for Rust developers is straightforward: SQL snippets, migrations, test fixtures, schema fragments, and other explicit `sql!` blocks become easier to read and review in Zed without requiring database-aware LSP support or any project-specific configuration. The change is also deliberately conservative: it is syntactic, opt-in through the existing `sql!` marker, test-backed, and leaves non-`sql!` macros alone. This should be a good fit for upstream because it improves behaviour Zed already supports instead of expanding the matching policy into ambiguous territory. It also follows the same general pattern used elsewhere in Zed's injections: when a host-language string literal contains an injected language, capture the literal body rather than the host-language wrapper syntax. I also want to call out related work in https://github.com/zed-industries/zed/pull/58016 and explicitly support that PR as well. The two changes are different in scope. This PR refines the existing generic `sql!` marker and does not add SQLx matching. PR #58016 is the SQLx-specific improvement, targeting `sqlx::query!`-style macros and functions where many Rust backend developers write production queries directly. That matters because SQLx users should not need to wrap SQLx calls in another marker macro just to get highlighting; SQLx's compile-time checking and call-site ergonomics are part of its value. I see these as complementary rather than competing improvements. This PR covers explicit generic SQL contexts such as snippets, migrations, fixtures, and non-SQLx embedded SQL. PR #58016 covers first-class SQLx call sites. Together, they move Zed toward a much stronger Rust embedded-SQL editing experience while keeping each individual change focused and reviewable. --- 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: - Improved SQL syntax highlighting in Rust `sql!` string literals.
Zed
Welcome to Zed, a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Installation
On macOS, Linux, and Windows you can download Zed directly or install Zed via your local package manager (macOS/Linux/Windows).
Other platforms are not yet available:
- Web (tracking discussion)
Developing Zed
Contributing
See CONTRIBUTING.md for ways you can contribute to Zed.
Also... we're hiring! Check out our jobs page for open roles.
Licensing
Zed source code is licensed primarily under GPL-3.0-or-later, with Apache-2.0 components where marked.
License information for third party dependencies must be correctly provided for CI to pass.
We use cargo-about to automatically comply with open source licenses. If CI is failing, check the following:
- Is it showing a
no license specifiederror for a crate you've created? If so, addpublish = falseunder[package]in your crate's Cargo.toml. - Is the error
failed to satisfy license requirementsfor a dependency? If so, first determine what license the project has and whether this system is sufficient to comply with this license's requirements. If you're unsure, ask a lawyer. Once you've verified that this system is acceptable add the license's SPDX identifier to theacceptedarray inscript/licenses/zed-licenses.toml. - Is
cargo-aboutunable to find the license for a dependency? If so, add a clarification field at the end ofscript/licenses/zed-licenses.toml, as specified in the cargo-about book.
Sponsorship
Zed is developed by Zed Industries, Inc., a for-profit company.
If you’d like to financially support the project, you can do so via GitHub Sponsors. Sponsorships go directly to Zed Industries and are used as general company revenue. There are no perks or entitlements associated with sponsorship.