Support yaml-language-server
as formatter without lsp
settings (#23612)
- Closes: https://github.com/zed-industries/zed/issues/20183
This commit is contained in:
parent
d5c7e0b1e3
commit
ed54af337d
2 changed files with 38 additions and 1 deletions
|
@ -143,7 +143,11 @@ impl LspAdapter for YamlLspAdapter {
|
|||
.language(Some(location), Some(&"YAML".into()), cx)
|
||||
.tab_size
|
||||
})?;
|
||||
let mut options = serde_json::json!({"[yaml]": {"editor.tabSize": tab_size}});
|
||||
|
||||
let mut options = serde_json::json!({
|
||||
"[yaml]": {"editor.tabSize": tab_size},
|
||||
"yaml": {"format": {"enable": true}}
|
||||
});
|
||||
|
||||
let project_options = cx.update(|cx| {
|
||||
language_server_settings(delegate.as_ref(), &Self::SERVER_NAME, cx)
|
||||
|
|
|
@ -30,6 +30,39 @@ You can configure various [yaml-language-server settings](https://github.com/red
|
|||
|
||||
Note, settings keys must be nested, so `yaml.keyOrdering` becomes `{"yaml": { "keyOrdering": true }}`.
|
||||
|
||||
## Formatting
|
||||
|
||||
By default Zed will use prettier for formatting YAML files.
|
||||
|
||||
### Prettier Formatting
|
||||
|
||||
You can customize the formatting behavior of Prettier. For example to use single-quotes in yaml files add the following to a `.prettierrc`:
|
||||
|
||||
```json
|
||||
{
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["*.yaml", "*.yml"]
|
||||
"options": {
|
||||
"singleQuote": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### yaml-language-server Formatting
|
||||
|
||||
To use `yaml-language-server` instead of Prettier for YAML formatting, add the following to your Zed settings.json:
|
||||
|
||||
```json
|
||||
"languages": {
|
||||
"YAML": {
|
||||
"formatter": "language_server"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Schemas
|
||||
|
||||
By default yaml-language-server will attempt to determine the correct schema for a given yaml file and retrieve the appropriate JSON Schema from [Json Schema Store](https://schemastore.org/).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue