Add sql language docs (#32003)
Closes: https://github.com/zed-industries/zed/issues/9537 Pairs with removing `prettier-plugin-sql` from the sql extension: - https://github.com/zed-extensions/sql/pull/19 Release Notes: - N/A
This commit is contained in:
parent
de225fd242
commit
01a77bb231
2 changed files with 69 additions and 0 deletions
|
@ -126,6 +126,7 @@
|
||||||
- [Scala](./languages/scala.md)
|
- [Scala](./languages/scala.md)
|
||||||
- [Scheme](./languages/scheme.md)
|
- [Scheme](./languages/scheme.md)
|
||||||
- [Shell Script](./languages/sh.md)
|
- [Shell Script](./languages/sh.md)
|
||||||
|
- [SQL](./languages/sql.md)
|
||||||
- [Svelte](./languages/svelte.md)
|
- [Svelte](./languages/svelte.md)
|
||||||
- [Swift](./languages/swift.md)
|
- [Swift](./languages/swift.md)
|
||||||
- [Tailwind CSS](./languages/tailwindcss.md)
|
- [Tailwind CSS](./languages/tailwindcss.md)
|
||||||
|
|
68
docs/src/languages/sql.md
Normal file
68
docs/src/languages/sql.md
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
# SQL
|
||||||
|
|
||||||
|
SQL files are handled by the [SQL Extension](https://github.com/zed-extensions/sql).
|
||||||
|
|
||||||
|
- Tree-sitter: [nervenes/tree-sitter-sql](https://github.com/nervenes/tree-sitter-sql)
|
||||||
|
|
||||||
|
### Formatting
|
||||||
|
|
||||||
|
Zed supports auto-formatting SQL using external tools like [`sql-formatter`](https://github.com/sql-formatter-org/sql-formatter).
|
||||||
|
|
||||||
|
1. Install `sql-formatter`:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install -g sql-formatter
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Ensure `shfmt` is available in your path and check the version:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
which sql-formatter
|
||||||
|
sql-formatter --version
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Configure Zed to automatically format SQL with `sql-formatter`:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"languages": {
|
||||||
|
"SQL": {
|
||||||
|
"formatter": {
|
||||||
|
"external": {
|
||||||
|
"command": "sql-formatter",
|
||||||
|
"arguments": ["--language", "mysql"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
```
|
||||||
|
|
||||||
|
Substitute your preferred [SQL Dialect] for `mysql` above (`duckdb`, `hive`, `mariadb`, `postgresql`, `redshift`, `snowflake`, `sqlite`, `spark`, etc).
|
||||||
|
|
||||||
|
You can add this to Zed project settings (`.zed/settings.json`) or via your Zed user settings (`~/.config/zed/settings.json`).
|
||||||
|
|
||||||
|
### Advanced Formatting
|
||||||
|
|
||||||
|
Sql-formatter also allows more precise control by providing [sql-formatter configuration options](https://github.com/sql-formatter-org/sql-formatter#configuration-options). To provide these, create a `sql-formatter.json` file in your project:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"language": "postgresql",
|
||||||
|
"tabWidth": 2,
|
||||||
|
"keywordCase": "upper",
|
||||||
|
"linesBetweenQueries": 2
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
When using a `sql-formatter.json` file you can use a more simplified set of Zed settings since the language need not be specified inline:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"languages": {
|
||||||
|
"SQL": {
|
||||||
|
"formatter": {
|
||||||
|
"external": {
|
||||||
|
"command": "sql-formatter"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
```
|
Loading…
Add table
Add a link
Reference in a new issue