SQL extension for Zed with smart formatting and linting — no external CLI tools required.
Formats SQL on save. Short queries stay on one line; complex queries break into readable multi-line form.
Short query — stays compact:
-- before
select * from users where id = 1
-- after
SELECT * FROM users WHERE id = 1Multi-column — each column indented:
-- before
select id, name, email from users where active = 1
-- after
SELECT
id,
name,
email
FROM users
WHERE active = 1Complex WHERE — conditions indented:
-- before
select * from users where id = 1 and status = 'active' or role = 'admin'
-- after
SELECT * FROM users
WHERE
id = 1
AND status = 'active'
OR role = 'admin'UPDATE — always multi-line:
-- before
update users set name = 'x' where id = 1
-- after
UPDATE users
SET name = 'x'
WHERE id = 1Formatting rules:
- Queries ≤ 80 chars with no JOIN, no subquery, simple WHERE → single line
- Multiple columns or function calls (
COUNT(*)) → indented underSELECT AND/ORconditions → indented underWHEREUPDATEalways multi-lineJOINand subqueries always multi-line- Comments and string literals preserved as-is
- Idempotent — formatting twice gives the same result
Powered by the tree-sitter-sql grammar. Syntax errors are highlighted immediately as you type — no need to run the query first.
-- typo in keyword → underlined with error
SELECT * FORM users WHERE id = 1
-- ^^^^ Syntax error near 'FORM users WHERE id = 1'
-- incomplete statement → caught instantly
SELECT * FROM users WHERE
-- ^ Syntax errorInline diagnostics for common SQL mistakes — catches dangerous patterns before they hit production.
Destructive queries without WHERE:
UPDATE users SET name = 'x' -- ⚠ UPDATE without WHERE clause — this will update all rows
DELETE FROM users -- ⚠ DELETE without WHERE clause — this will delete all rowsNULL comparison:
WHERE name = NULL -- ✗ Use IS NULL / IS NOT NULL instead of = NULL
WHERE name IS NULL -- ✓SELECT pitfalls:
SELECT * FROM users -- ⚠ Avoid SELECT *, specify columns explicitly
SELECT FROM users -- ✗ Missing column list in SELECTEmpty IN list:
WHERE id IN () -- ✗ IN () with empty list — condition is always falsePagination issues:
SELECT * FROM users LIMIT 10 -- ⚠ LIMIT without ORDER BY may produce inconsistent results
SELECT * FROM users ORDER BY id LIMIT 10 -- ✓Always-true conditions (debug code left in):
WHERE 1 = 1 -- ⚠ Condition '1 = 1' is always true — likely debug codeSubquery without alias:
SELECT * FROM (SELECT id FROM users) -- ⚠ Subquery in FROM must have an alias (AS name)
SELECT * FROM (SELECT id FROM users) AS u -- ✓The extension is available in the Zed extension marketplace. Search for SQL Tools in the Extensions panel (cmd+shift+x on macOS).
Zed will automatically download the sql-lsp language server binary on first use.
To enable format-on-save, add to your Zed settings:
{
"languages": {
"SQL": {
"formatter": "language_server",
"format_on_save": "on"
}
}
}Uses DerekStride/tree-sitter-sql for parsing and syntax highlighting.